Conditions | 3 |
Paths | 1 |
Total Lines | 35 |
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 | protected $queue; |
||
16 | |||
17 | public function __construct(object $action, ?string $queue) |
||
18 | { |
||
19 | $this->action = $action; |
||
20 | $this->onQueue($queue); |
||
21 | } |
||
22 | |||
23 | public function execute(...$parameters) |
||
24 | { |
||
25 | return dispatch(new ActionJob($this->action, $parameters)) |
||
26 | ->onQueue($this->queue); |
||
27 | } |
||
28 | |||
29 | protected function onQueue(?string $queue): void |
||
30 | { |
||
31 | if (is_string($queue)) { |
||
32 | $this->queue = $queue; |
||
33 | |||
34 | return; |
||
35 | } |
||
36 | |||
37 | if (isset($this->action->queue)) { |
||
38 | $this->queue = $this->action->queue; |
||
39 | } |
||
40 | } |
||
41 | }; |
||
42 | |||
43 | return $class; |
||
44 | } |
||
45 | |||
51 |