Skip to content

Commit 9839494

Browse files
committed
Merge remote-tracking branch 'origin/feature/rejection-reason' into feature/upgrade-pipeline-contracts
2 parents dcdcd18 + a18b984 commit 9839494

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

src/PipelineRunner.php

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Kiboko\Component\Pipeline;
66

7+
use Kiboko\Component\Bucket\RejectionResultBucket;
8+
use Kiboko\Component\Bucket\RejectionWithReasonResultBucket;
79
use Kiboko\Contract\Bucket\AcceptanceResultBucketInterface;
810
use Kiboko\Contract\Bucket\RejectionResultBucketInterface;
911
use Kiboko\Contract\Bucket\ResultBucketInterface;
@@ -43,17 +45,34 @@ public function run(
4345
}
4446

4547
if ($bucket instanceof RejectionResultBucketInterface) {
46-
foreach ($bucket->walkRejection() as $line) {
47-
$rejection->reject($line);
48-
$state->reject();
48+
if ($bucket instanceof RejectionResultBucket) {
49+
foreach ($bucket->walkRejection() as $line) {
50+
$rejection->reject($line);
51+
$state->reject();
4952

50-
$this->logger->log(
51-
$this->rejectionLevel,
52-
'Some data was rejected from the pipeline',
53-
[
54-
'line' => $line,
55-
]
56-
);
53+
$this->logger->log(
54+
$this->rejectionLevel,
55+
'Some data was rejected from the pipeline',
56+
[
57+
'line' => $line,
58+
]
59+
);
60+
}
61+
}
62+
63+
if ($bucket instanceof RejectionWithReasonResultBucket) {
64+
foreach ($bucket->walkRejection() as $line) {
65+
$rejection->rejectWithReason($line, $bucket->getReason());
66+
$state->reject();
67+
68+
$this->logger->log(
69+
$this->rejectionLevel,
70+
'Some data was rejected from the pipeline',
71+
[
72+
'line' => $line,
73+
]
74+
);
75+
}
5776
}
5877
}
5978

0 commit comments

Comments
 (0)