Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/Rejection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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,
Expand Down Expand Up @@ -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([
Expand All @@ -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),
Expand All @@ -119,4 +113,10 @@ public function initialize(): void
autoDelete: true,
);
}

public function teardown(): void
{
$this->channel->close();
$this->connection->stop();
}
}
3 changes: 2 additions & 1 deletion src/State.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down