Skip to content

Commit 9694ef8

Browse files
committed
Fixed filtering rejections code
1 parent 8382034 commit 9694ef8

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

src/Plugin/Filtering/Builder/Drop.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ final class Drop implements StepBuilderInterface
1313
private ?Node\Expr $logger = null;
1414
private ?Node\Expr $rejection = null;
1515
private ?Node\Expr $state = null;
16+
17+
private ?string $reason = null;
18+
1619
/** @var list<?Node\Expr> */
1720
private array $exclusions = [];
1821

@@ -48,6 +51,13 @@ public function withExclusions(Node\Expr ...$exclusions): self
4851
return $this;
4952
}
5053

54+
public function withReason(string $reason): self
55+
{
56+
$this->reason = $reason;
57+
58+
return $this;
59+
}
60+
5161
private function buildExclusions(Node\Expr ...$exclusions): Node\Expr
5262
{
5363
if (\count($exclusions) > 3) {
@@ -122,16 +132,15 @@ class: new Node\Stmt\Class_(null, [
122132
new Node\Expr\Variable('input'),
123133
new Node\Expr\Yield_(
124134
new Node\Expr\New_(
125-
class: new Node\Name\FullyQualified('Kiboko\\Component\\Bucket\\RejectionResultBucket'),
135+
class: new Node\Name\FullyQualified(
136+
\Kiboko\Component\Bucket\RejectionResultBucket::class
137+
),
126138
args: [
127139
new Node\Arg(
128-
new Node\Expr\MethodCall(
129-
new Node\Expr\Variable('exception'),
130-
'getMessage'
131-
),
140+
new Node\Scalar\String_($this->reason),
132141
),
133142
new Node\Arg(
134-
new Node\Expr\Variable('exception'),
143+
new Node\Expr\ConstFetch(new Node\Name('null')),
135144
),
136145
new Node\Arg(
137146
new Node\Expr\Variable('input'),

src/Plugin/Filtering/Builder/Reject.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ final class Reject implements StepBuilderInterface
1313
private ?Node\Expr $logger = null;
1414
private ?Node\Expr $rejection = null;
1515
private ?Node\Expr $state = null;
16+
17+
private ?string $reason = null;
18+
1619
/** @var list<?Node\Expr> */
1720
private array $exclusions = [];
1821

@@ -48,6 +51,13 @@ public function withExclusions(Node\Expr ...$exclusions): self
4851
return $this;
4952
}
5053

54+
public function withReason(string $reason): self
55+
{
56+
$this->reason = $reason;
57+
58+
return $this;
59+
}
60+
5161
private function buildExclusions(Node\Expr ...$exclusions): Node\Expr
5262
{
5363
if (\count($exclusions) > 3) {
@@ -127,13 +137,10 @@ class: new Node\Name\FullyQualified(
127137
),
128138
args: [
129139
new Node\Arg(
130-
new Node\Expr\MethodCall(
131-
new Node\Expr\Variable('exception'),
132-
'getMessage'
133-
),
140+
new Node\Scalar\String_($this->reason),
134141
),
135142
new Node\Arg(
136-
new Node\Expr\Variable('exception'),
143+
new Node\Expr\ConstFetch(new Node\Name('null')),
137144
),
138145
new Node\Arg(
139146
new Node\Expr\Variable('input'),

0 commit comments

Comments
 (0)