77use Closure ;
88use Fraction \Configurable \DeferUsing ;
99use Fraction \Configurable \QueueUsing ;
10- use Fraction \Configurable \RescuedUsing ;
1110use Fraction \Contracts \ShouldInterpreter ;
1211use Fraction \Exceptions \PreventDeferQueueSameTime ;
13- use Fraction \Interpreters \AsDefault ;
14- use Fraction \Interpreters \AsDefer ;
15- use Fraction \Interpreters \AsQueue ;
16- use Fraction \ValueObjects \Then ;
12+ use Fraction \Handlers \AsDefer ;
13+ use Fraction \Handlers \AsQueue ;
14+ use Fraction \Handlers \AsSync ;
1715use Illuminate \Contracts \Container \BindingResolutionException ;
1816use Illuminate \Contracts \Support \Arrayable ;
1917use Illuminate \Foundation \Application ;
2321
2422final class FractionBuilder implements Arrayable
2523{
26- /**
27- * The array of "then" hooks.
28- *
29- * @var array<int, string>
30- */
31- private array $ then = [];
32-
33- /**
34- * Configuration for queueing the action.
35- */
36- private ?QueueUsing $ queued = null ;
37-
38- /**
39- * Configuration for deferring the action.
40- */
41- private ?DeferUsing $ deferred = null ;
42-
43- /**
44- * Indicates if the action should be rescued.
45- */
46- private ?RescuedUsing $ rescued = null ;
24+ use Concerns \UsingDefer;
25+ use Concerns \UsingQueue;
26+ use Concerns \UsingRescue;
27+ use Concerns \UsingThen;
4728
4829 public function __construct (
4930 public Application $ application ,
@@ -69,7 +50,7 @@ public function __invoke(...$arguments): mixed
6950 $ interpret = match (true ) {
7051 $ this ->queued instanceof QueueUsing => AsQueue::class,
7152 $ this ->deferred instanceof DeferUsing => AsDefer::class,
72- default => AsDefault ::class,
53+ default => AsSync ::class,
7354 };
7455
7556 /** @var ShouldInterpreter $interpreter */
@@ -95,57 +76,6 @@ public function __invoke(...$arguments): mixed
9576 return $ result ;
9677 }
9778
98- /**
99- * Register a "then" hook.
100- */
101- public function then (string |UnitEnum $ action ): self
102- {
103- $ this ->then [] = new Then ($ this ->action , $ action );
104-
105- return $ this ;
106- }
107-
108- /**
109- * Enable the action to be queued.
110- *
111- * @return $this
112- */
113- public function queued (
114- mixed $ delay = null ,
115- ?string $ queue = null ,
116- ?string $ connection = null ,
117- ): self {
118- $ this ->queued = new QueueUsing ($ delay , $ queue , $ connection );
119-
120- return $ this ;
121- }
122-
123- /**
124- * Enable the action to be deferred.
125- *
126- * @return $this
127- */
128- public function deferred (
129- bool $ always = false ,
130- ?string $ name = null ,
131- ): self {
132- $ this ->deferred = new DeferUsing ($ name , $ always );
133-
134- return $ this ;
135- }
136-
137- /**
138- * Enable the action to be rescued.
139- *
140- * @return $this
141- */
142- public function rescued (mixed $ default = null ): self
143- {
144- $ this ->rescued = new RescuedUsing ($ default );
145-
146- return $ this ;
147- }
148-
14979 /** {@inheritDoc} */
15080 public function toArray (): array
15181 {
0 commit comments