|
15 | 15 | use Fraction\Interpreters\AsQueue; |
16 | 16 | use Fraction\ValueObjects\Then; |
17 | 17 | use Illuminate\Contracts\Container\BindingResolutionException; |
| 18 | +use Illuminate\Contracts\Support\Arrayable; |
18 | 19 | use Illuminate\Foundation\Application; |
19 | 20 | use InvalidArgumentException; |
20 | 21 | use Laravel\SerializableClosure\SerializableClosure; |
21 | 22 | use UnitEnum; |
22 | 23 |
|
23 | | -final class FractionBuilder |
| 24 | +final class FractionBuilder implements Arrayable |
24 | 25 | { |
25 | | - public array $then = []; |
| 26 | + private array $then = []; |
26 | 27 |
|
27 | | - public ?QueueUsing $queued = null; |
| 28 | + private ?QueueUsing $queued = null; |
28 | 29 |
|
29 | | - public ?DeferUsing $deferred = null; |
| 30 | + private ?DeferUsing $deferred = null; |
30 | 31 |
|
31 | 32 | public function __construct( |
32 | 33 | public Application $application, |
@@ -59,7 +60,7 @@ public function __invoke(...$arguments): mixed |
59 | 60 |
|
60 | 61 | $instance = $interpreter->then($this->then); |
61 | 62 |
|
62 | | - if ($interpreter instanceof Configurable) { |
| 63 | + if ($interpreter instanceof Configurable && ($this->queued || $this->deferred)) { |
63 | 64 | $interpreter->configure($this->queued?->toArray() ?? $this->deferred->toArray()); |
64 | 65 | } |
65 | 66 |
|
@@ -97,4 +98,15 @@ public function deferred( |
97 | 98 |
|
98 | 99 | return $this; |
99 | 100 | } |
| 101 | + |
| 102 | + public function toArray(): array |
| 103 | + { |
| 104 | + return [ |
| 105 | + 'action' => $this->action, |
| 106 | + 'closure' => $this->closure, |
| 107 | + 'then' => $this->then, |
| 108 | + 'queued' => $this->queued, |
| 109 | + 'deferred' => $this->deferred, |
| 110 | + ]; |
| 111 | + } |
100 | 112 | } |
0 commit comments