anfischer /
laravel-foundation
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | namespace Anfischer\Foundation\Job\Concerns; |
||||||
| 4 | |||||||
| 5 | use Anfischer\Foundation\Job\Job; |
||||||
| 6 | use Illuminate\Http\Request; |
||||||
| 7 | use Illuminate\Support\Collection; |
||||||
| 8 | |||||||
| 9 | trait DispatchesJobs |
||||||
| 10 | { |
||||||
| 11 | /** |
||||||
| 12 | * Beautifier function to be called instead of the |
||||||
| 13 | * laravel function dispatch. |
||||||
| 14 | * |
||||||
| 15 | * @param mixed $job |
||||||
| 16 | * @param array|\Illuminate\Http\Request $arguments |
||||||
| 17 | * @param array $extra |
||||||
| 18 | * |
||||||
| 19 | * @return mixed |
||||||
| 20 | */ |
||||||
| 21 | 12 | public function run($job, $arguments = [], array $extra = []) |
|||||
| 22 | { |
||||||
| 23 | 12 | return $this->dispatch($this->prepare($job, $arguments, $extra)); |
|||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
| 24 | } |
||||||
| 25 | |||||||
| 26 | /** |
||||||
| 27 | * Runs the job in the given queue. |
||||||
| 28 | * |
||||||
| 29 | * @param string $job |
||||||
| 30 | * @param array|\Illuminate\Http\Request $arguments |
||||||
| 31 | * @param array $extra |
||||||
| 32 | * @param string $queue |
||||||
| 33 | * |
||||||
| 34 | * @return mixed |
||||||
| 35 | */ |
||||||
| 36 | 6 | public function runInQueue($job, $arguments = [], array $extra = [], string $queue = 'default') |
|||||
| 37 | { |
||||||
| 38 | 6 | $job = $this->prepare($job, $arguments, $extra); |
|||||
| 39 | 6 | $job->onQueue($queue); |
|||||
|
0 ignored issues
–
show
The method
onQueue() does not exist on Anfischer\Foundation\Job\Job. It seems like you code against a sub-type of Anfischer\Foundation\Job\Job such as Anfischer\Foundation\Job\QueueableJob.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 40 | |||||||
| 41 | 6 | return $this->dispatch($job); |
|||||
| 42 | } |
||||||
| 43 | |||||||
| 44 | |||||||
| 45 | /** |
||||||
| 46 | * Prepare a job by marshalling it if needed. |
||||||
| 47 | * |
||||||
| 48 | * @param $job |
||||||
| 49 | * @param $arguments |
||||||
| 50 | * @param array $extra |
||||||
| 51 | * @return mixed |
||||||
| 52 | */ |
||||||
| 53 | 18 | private function prepare($job, $arguments, array $extra) : Job |
|||||
| 54 | { |
||||||
| 55 | 18 | if ($arguments instanceof Request) { |
|||||
| 56 | 6 | return $this->marshal($job, $arguments, $extra); |
|||||
|
0 ignored issues
–
show
It seems like
marshal() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 57 | } |
||||||
| 58 | |||||||
| 59 | 12 | if (! \is_object($job)) { |
|||||
| 60 | 6 | return $this->marshal($job, new Collection($arguments), $extra); |
|||||
| 61 | } |
||||||
| 62 | |||||||
| 63 | 6 | return $job; |
|||||
| 64 | } |
||||||
| 65 | } |
||||||
| 66 |