Conditions | 3 |
Paths | 1 |
Total Lines | 36 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
10 | public function onQueue(?string $queue = null) |
||
11 | { |
||
12 | /** @var self $class */ |
||
13 | $class = new class($this, $queue) { |
||
14 | protected $action; |
||
15 | |||
16 | protected $queue; |
||
17 | |||
18 | public function __construct(object $action, ?string $queue) |
||
19 | { |
||
20 | $this->action = $action; |
||
21 | $this->onQueue($queue); |
||
22 | } |
||
23 | |||
24 | public function execute(...$parameters) |
||
25 | { |
||
26 | return dispatch(new ActionJob($this->action, $parameters)) |
||
27 | ->onQueue($this->queue); |
||
28 | } |
||
29 | |||
30 | protected function onQueue(?string $queue): void |
||
31 | { |
||
32 | if (is_string($queue)) { |
||
33 | $this->queue = $queue; |
||
34 | |||
35 | return; |
||
36 | } |
||
37 | |||
38 | if (isset($this->action->queue)) { |
||
39 | $this->queue = $this->action->queue; |
||
40 | } |
||
41 | } |
||
42 | }; |
||
43 | |||
44 | return $class; |
||
45 | } |
||
46 | |||
57 |