Debian Codegraph @

lib/3rdParty/composer/illuminate/support/Facades/Bus.php

raw symbols SCIP
1 <?php
2
3 namespace Illuminate\Support\Facades;
4
5 use Illuminate\Bus\BatchRepository;
6 use Illuminate\Contracts\Bus\Dispatcher as BusDispatcherContract;
7 use Illuminate\Foundation\Bus\PendingChain;
8 use Illuminate\Support\Testing\Fakes\BusFake;
9
10 /**
11 * @method static mixed dispatch(mixed $command)
12 * @method static mixed dispatchSync(mixed $command, mixed $handler = null)
13 * @method static mixed dispatchNow(mixed $command, mixed $handler = null)
14 * @method static \Illuminate\Bus\Batch|null findBatch(string $batchId)
15 * @method static \Illuminate\Bus\PendingBatch batch(\Illuminate\Support\Collection|mixed $jobs)
16 * @method static \Illuminate\Foundation\Bus\PendingChain chain(\Illuminate\Support\Collection|array|null $jobs = null)
17 * @method static bool hasCommandHandler(mixed $command)
18 * @method static mixed getCommandHandler(mixed $command)
19 * @method static mixed dispatchToQueue(mixed $command)
20 * @method static void dispatchAfterResponse(mixed $command, mixed $handler = null)
21 * @method static \Illuminate\Bus\Dispatcher pipeThrough(array $pipes)
22 * @method static \Illuminate\Bus\Dispatcher map(array $map)
23 * @method static \Illuminate\Bus\Dispatcher withDispatchingAfterResponses()
24 * @method static \Illuminate\Bus\Dispatcher withoutDispatchingAfterResponses()
25 * @method static \Illuminate\Support\Testing\Fakes\BusFake except(array|string $jobsToDispatch)
26 * @method static void assertDispatched(string|\Closure $command, callable|int|null $callback = null)
27 * @method static void assertDispatchedOnce(string|\Closure $command)
28 * @method static void assertDispatchedTimes(string|\Closure $command, int $times = 1)
29 * @method static void assertNotDispatched(string|\Closure $command, callable|null $callback = null)
30 * @method static void assertNothingDispatched()
31 * @method static void assertDispatchedSync(string|\Closure $command, callable|int|null $callback = null)
32 * @method static void assertDispatchedSyncTimes(string|\Closure $command, int $times = 1)
33 * @method static void assertNotDispatchedSync(string|\Closure $command, callable|null $callback = null)
34 * @method static void assertDispatchedAfterResponse(string|\Closure $command, callable|int|null $callback = null)
35 * @method static void assertDispatchedAfterResponseTimes(string|\Closure $command, int $times = 1)
36 * @method static void assertNotDispatchedAfterResponse(string|\Closure $command, callable|null $callback = null)
37 * @method static void assertChained(array $expectedChain)
38 * @method static void assertNothingChained()
39 * @method static void assertDispatchedWithoutChain(string|\Closure $command, callable|null $callback = null)
40 * @method static \Illuminate\Support\Testing\Fakes\ChainedBatchTruthTest chainedBatch(\Closure $callback)
41 * @method static void assertBatched(array|callable $callback)
42 * @method static void assertBatchCount(int $count)
43 * @method static void assertNothingBatched()
44 * @method static void assertNothingPlaced()
45 * @method static \Illuminate\Support\Collection dispatched(string $command, callable|null $callback = null)
46 * @method static \Illuminate\Support\Collection dispatchedSync(string $command, callable|null $callback = null)
47 * @method static \Illuminate\Support\Collection dispatchedAfterResponse(string $command, callable|null $callback = null)
48 * @method static \Illuminate\Support\Collection batched(callable $callback)
49 * @method static bool hasDispatched(string $command)
50 * @method static bool hasDispatchedSync(string $command)
51 * @method static bool hasDispatchedAfterResponse(string $command)
52 * @method static \Illuminate\Bus\Batch dispatchFakeBatch(string $name = '')
53 * @method static \Illuminate\Bus\Batch recordPendingBatch(\Illuminate\Bus\PendingBatch $pendingBatch)
54 * @method static \Illuminate\Support\Testing\Fakes\BusFake serializeAndRestore(bool $serializeAndRestore = true)
55 * @method static array dispatchedBatches()
56 *
57 * @see \Illuminate\Bus\Dispatcher
58 * @see \Illuminate\Support\Testing\Fakes\BusFake
59 */
60 class Bus extends Facade
61 {
62 /**
63 * Replace the bound instance with a fake.
64 *
65 * @param array|string $jobsToFake
66 * @param \Illuminate\Bus\BatchRepository|null $batchRepository
67 * @return \Illuminate\Support\Testing\Fakes\BusFake
68 */
69 public static function fake($jobsToFake = [], ?BatchRepository $batchRepository = null)
70 {
71 $actualDispatcher = static::isFake()
72 ? static::getFacadeRoot()->dispatcher
73 : static::getFacadeRoot();
74
75 return tap(new BusFake($actualDispatcher, $jobsToFake, $batchRepository), function ($fake) {
76 static::swap($fake);
77 });
78 }
79
80 /**
81 * Dispatch the given chain of jobs.
82 *
83 * @param mixed $jobs
84 * @return \Illuminate\Foundation\Bus\PendingDispatch
85 */
86 public static function dispatchChain($jobs)
87 {
88 $jobs = is_array($jobs) ? $jobs : func_get_args();
89
90 return (new PendingChain(array_shift($jobs), $jobs))
91 ->dispatch();
92 }
93
94 /**
95 * Get the registered name of the component.
96 *
97 * @return string
98 */
99 protected static function getFacadeAccessor()
100 {
101 return BusDispatcherContract::class;
102 }
103 }