@@ -16,10 +16,6 @@ final class Drop implements StepBuilderInterface
1616 /** @var list<?Node\Expr> */
1717 private array $ exclusions = [];
1818
19- public function __construct ()
20- {
21- }
22-
2319 public function withLogger (Node \Expr $ logger ): self
2420 {
2521 $ this ->logger = $ logger ;
@@ -41,55 +37,13 @@ public function withState(Node\Expr $state): self
4137 return $ this ;
4238 }
4339
44- public function withExclusions (Node \ Expr ...$ exclusions ): self
40+ public function withExclusions (Node ...$ exclusions ): self
4541 {
4642 array_push ($ this ->exclusions , ...$ exclusions );
4743
4844 return $ this ;
4945 }
5046
51- private function buildExclusions (Node \Expr ...$ exclusions ): Node \Expr
52- {
53- if (\count ($ exclusions ) > 3 ) {
54- $ length = \count ($ exclusions );
55- $ middle = (int ) floor ($ length / 2 );
56- $ left = \array_slice ($ exclusions , 0 , $ middle );
57- $ right = \array_slice ($ exclusions , $ middle , $ length );
58-
59- return new Node \Expr \BinaryOp \BooleanAnd (
60- $ this ->buildExclusions (...$ left ),
61- $ this ->buildExclusions (...$ right ),
62- );
63- }
64-
65- if (\count ($ exclusions ) > 2 ) {
66- $ right = array_shift ($ exclusions );
67-
68- return new Node \Expr \BinaryOp \BooleanAnd (
69- $ this ->buildExclusions (...$ exclusions ),
70- $ right ,
71- );
72- }
73-
74- if (\count ($ exclusions ) > 1 ) {
75- $ left = array_pop ($ exclusions );
76- $ right = array_pop ($ exclusions );
77-
78- return new Node \Expr \BinaryOp \BooleanAnd (
79- $ left ,
80- $ right ,
81- );
82- }
83-
84- if (\count ($ exclusions ) > 0 ) {
85- return array_pop ($ exclusions );
86- }
87-
88- return new Node \Expr \ConstFetch (
89- new Node \Name ('false ' ),
90- );
91- }
92-
9347 public function getNode (): Node
9448 {
9549 return new Node \Expr \New_ (
@@ -113,24 +67,7 @@ class: new Node\Stmt\Class_(null, [
11367 new Node \Name ('true ' ),
11468 ),
11569 [
116- new Node \Stmt \If_ (
117- $ this ->buildExclusions (...$ this ->exclusions ),
118- [
119- 'stmts ' => [
120- new Node \Stmt \Expression (
121- new Node \Expr \Assign (
122- new Node \Expr \Variable ('input ' ),
123- new Node \Expr \Yield_ (
124- new Node \Expr \New_ (
125- new Node \Name \FullyQualified ('Kiboko \\Component \\Bucket \\RejectionResultBucket ' ),
126- ),
127- ),
128- ),
129- ),
130- new Node \Stmt \Continue_ (),
131- ],
132- ]
133- ),
70+ ...$ this ->exclusions ,
13471 new Node \Stmt \Expression (
13572 new Node \Expr \Assign (
13673 new Node \Expr \Variable ('input ' ),
@@ -146,11 +83,6 @@ class: new Node\Stmt\Class_(null, [
14683 ),
14784 ],
14885 ),
149- new Node \Stmt \Expression (
150- new Node \Expr \Yield_ (
151- new Node \Expr \Variable ('input ' )
152- ),
153- ),
15486 ])
15587 ->getNode (),
15688 ],
0 commit comments