Debian Codegraph @

lib/3rdParty/composer/illuminate/support/Testing/Fakes/PendingChainFake.php

raw symbols SCIP
1 <?php
2
3 namespace Illuminate\Support\Testing\Fakes;
4
5 use Closure;
6 use Illuminate\Foundation\Bus\PendingChain;
7 use Illuminate\Queue\CallQueuedClosure;
8
9 class PendingChainFake extends PendingChain
10 {
11 /**
12 * The fake bus instance.
13 *
14 * @var \Illuminate\Support\Testing\Fakes\BusFake
15 */
16 protected $bus;
17
18 /**
19 * Create a new pending chain instance.
20 *
21 * @param \Illuminate\Support\Testing\Fakes\BusFake $bus
22 * @param mixed $job
23 * @param array $chain
24 */
25 public function __construct(BusFake $bus, $job, $chain)
26 {
27 $this->bus = $bus;
28 $this->job = $job;
29 $this->chain = $chain;
30 }
31
32 /**
33 * Dispatch the job with the given arguments.
34 *
35 * @return \Illuminate\Foundation\Bus\PendingDispatch
36 */
37 public function dispatch()
38 {
39 if (is_string($this->job)) {
40 $firstJob = new $this->job(...func_get_args());
41 } elseif ($this->job instanceof Closure) {
42 $firstJob = CallQueuedClosure::create($this->job);
43 } else {
44 $firstJob = $this->job;
45 }
46
47 $firstJob->allOnConnection($this->connection);
48 $firstJob->allOnQueue($this->queue);
49 $firstJob->chain($this->chain);
50 $firstJob->delay($this->delay);
51 $firstJob->chainCatchCallbacks = $this->catchCallbacks();
52
53 return $this->bus->dispatch($firstJob);
54 }
55 }