Skip to content

Commit

Permalink
Added a way to add rejection reason
Browse files Browse the repository at this point in the history
  • Loading branch information
sebprt committed Oct 20, 2023
1 parent 3bc1ba7 commit a18b984
Showing 1 changed file with 30 additions and 11 deletions.
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 @@ public function run(
}

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

0 comments on commit a18b984

Please sign in to comment.