WatchableDispatchesJobs   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A dispatch() 0 8 1
A dispatchNow() 0 6 1
1
<?php namespace Maqe\Qwatcher\Traits;
2
3
use DB;
4
use Illuminate\Contracts\Bus\Dispatcher;
5
use Maqe\Qwatcher\Facades\Qwatch;
6
use Maqe\Qwatcher\Tracks\QueueTracks;
7
8
trait WatchableDispatchesJobs
9
{
10
    /**
11
     * Dispatch a job to its appropriate handler.
12
     *
13
     * @param  mixed  $job
14
     * @param  array  $meta
15
     * @return mixed
16
     */
17
    public function dispatch($job, array $meta = [])
18
    {
19
        $id = app(Dispatcher::class)->dispatch($job);
20
21
        Qwatch::tracks(new QueueTracks($id, $job, $meta));
22
23
        return $id;
24
    }
25
26
    /**
27
     * Dispatch a command to its appropriate handler in the current process.
28
     *
29
     * @param  mixed  $job
30
     * @return mixed
31
     */
32
    public function dispatchNow($job)
33
    {
34
        Qwatch::queued($job);
35
36
        return app(Dispatcher::class)->dispatchNow($job);
37
    }
38
}
39