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

WatchableDispatchesJobs::dispatch()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 8
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 4
nc 1
nop 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