Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a way to add rejection reason #16

Merged
merged 1 commit into from
Nov 14, 2023
Merged
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
41 changes: 30 additions & 11 deletions src/PipelineRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Kiboko\Component\Pipeline;

use Kiboko\Component\Bucket\RejectionResultBucket;
use Kiboko\Component\Bucket\RejectionWithReasonResultBucket;
use Kiboko\Contract\Bucket\AcceptanceResultBucketInterface;
use Kiboko\Contract\Bucket\RejectionResultBucketInterface;
use Kiboko\Contract\Bucket\ResultBucketInterface;
Expand Down Expand Up @@ -44,17 +46,34 @@
}

if ($bucket instanceof RejectionResultBucketInterface) {
foreach ($bucket->walkRejection() as $line) {
$rejection->reject($line);
$state->reject();

$this->logger->log(
$this->rejectionLevel,
'Some data was rejected from the pipeline',
[
'line' => $line,
]
);
if ($bucket instanceof RejectionResultBucket) {
foreach ($bucket->walkRejection() as $line) {
$rejection->reject($line);
$state->reject();

$this->logger->log(
$this->rejectionLevel,
'Some data was rejected from the pipeline',
[
'line' => $line,
]
);
}
}

if ($bucket instanceof RejectionWithReasonResultBucket) {

Check failure on line 64 in src/PipelineRunner.php

View workflow job for this annotation

GitHub Actions / phpstan

Class Kiboko\Component\Bucket\RejectionWithReasonResultBucket not found.

Check failure on line 64 in src/PipelineRunner.php

View workflow job for this annotation

GitHub Actions / phpstan

Class Kiboko\Component\Bucket\RejectionWithReasonResultBucket not found.
foreach ($bucket->walkRejection() as $line) {

Check failure on line 65 in src/PipelineRunner.php

View workflow job for this annotation

GitHub Actions / phpstan

Call to method walkRejection() on an unknown class Kiboko\Component\Bucket\RejectionWithReasonResultBucket.

Check failure on line 65 in src/PipelineRunner.php

View workflow job for this annotation

GitHub Actions / phpstan

Call to method walkRejection() on an unknown class Kiboko\Component\Bucket\RejectionWithReasonResultBucket.
$rejection->rejectWithReason($line, $bucket->getReason());

Check failure on line 66 in src/PipelineRunner.php

View workflow job for this annotation

GitHub Actions / phpstan

Call to an undefined method Kiboko\Contract\Pipeline\RejectionInterface::rejectWithReason().

Check failure on line 66 in src/PipelineRunner.php

View workflow job for this annotation

GitHub Actions / phpstan

Call to method getReason() on an unknown class Kiboko\Component\Bucket\RejectionWithReasonResultBucket.
$state->reject();

$this->logger->log(
$this->rejectionLevel,
'Some data was rejected from the pipeline',
[
'line' => $line,
]
);
}
}
}

Expand Down
Loading