Completed
Pull Request — master (#21)
by
unknown
04:20
created

WatchableDispatchesJobs   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

2 Methods

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