Skip to content

Commit a18b984

Browse files
committed
Added a way to add rejection reason
1 parent 3bc1ba7 commit a18b984

File tree

1 file changed

+30
-11
lines changed

1 file changed

+30
-11
lines changed

src/PipelineRunner.php

Lines changed: 30 additions & 11 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;
@@ -44,17 +46,34 @@ public function run(
4446
}
4547

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

0 commit comments

Comments
 (0)