diff --git a/src/Rejection.php b/src/Rejection.php index 7305c59..6141f8d 100644 --- a/src/Rejection.php +++ b/src/Rejection.php @@ -6,10 +6,9 @@ use Bunny\Channel; use Bunny\Client; -use Kiboko\Contract\Pipeline\RejectionInterface; -use Kiboko\Contract\Pipeline\StepCodeInterface; +use Kiboko\Contract\Pipeline\StepRejectionInterface; -final readonly class Rejection implements RejectionInterface +final readonly class Rejection implements StepRejectionInterface { private Channel $channel; @@ -29,12 +28,6 @@ public function __construct( ); } - public function teardown(): void - { - $this->channel->close(); - $this->connection->stop(); - } - public static function withoutAuthentication( string $stepUuid, string $host, @@ -77,7 +70,7 @@ public static function withAuthentication( return new self($connection, stepUuid: $stepUuid, topic: $topic, exchange: $exchange); } - public function reject(StepCodeInterface $step, array|object $rejection, ?\Throwable $exception = null): void + public function reject(object|array $rejection, ?\Throwable $exception = null): void { $this->channel->publish( \json_encode([ @@ -93,11 +86,12 @@ public function reject(StepCodeInterface $step, array|object $rejection, ?\Throw ); } - public function rejectWithReason(StepCodeInterface $step, array|object $rejection, string $reason, ?\Throwable $exception = null): void + public function rejectWithReason(object|array $rejection, string $reason, ?\Throwable $exception = null): void { $this->channel->publish( \json_encode([ 'item' => $rejection, + 'reason' => $reason, 'exception' => $exception, 'step' => $this->stepUuid, ], \JSON_THROW_ON_ERROR), @@ -119,4 +113,10 @@ public function initialize(): void autoDelete: true, ); } + + public function teardown(): void + { + $this->channel->close(); + $this->connection->stop(); + } } diff --git a/src/State.php b/src/State.php index 04103c8..e120020 100644 --- a/src/State.php +++ b/src/State.php @@ -16,7 +16,8 @@ public function __construct( private readonly StateManager $manager, private readonly string $stepCode, private readonly string $stepLabel, - ) {} + ) { + } public function accept(int $count = 1): void {