Passed
Push — master ( 6b0e6b...43789e )
by Stephen
03:30
created

TrackActivityJob::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 6
dl 0
loc 13
rs 10
1
<?php
2
3
namespace Sfneal\Tracking\Jobs;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Sfneal\Queueables\AbstractJob;
7
use Sfneal\Tracking\Actions\TrackActivityAction;
8
9
class TrackActivityJob extends AbstractJob
10
{
11
    /**
12
     * @var string Queue to use
13
     */
14
    public $queue = 'tracking';
15
16
    public $model;
17
    public $request_token;
18
    public $user_id;
19
    public $route;
20
    public $model_changes;
21
    public $description;
22
23
    /**
24
     * Track a user's route.
25
     *
26
     * @param Model $model
27
     * @param string $request_token
28
     * @param int $user_id
29
     * @param string $route
30
     * @param array $model_changes
31
     * @param string|null $description
32
     */
33
    public function __construct(Model $model,
34
                                string $request_token,
35
                                int $user_id,
36
                                string $route,
37
                                array $model_changes = [],
38
                                string $description = null)
39
    {
40
        $this->model = $model;
41
        $this->request_token = $request_token;
42
        $this->user_id = $user_id;
43
        $this->route = $route;
44
        $this->model_changes = $model_changes;
45
        $this->description = $description;
46
    }
47
48
    /**
49
     * Execute the job.
50
     *
51
     * @return void
52
     */
53
    public function handle()
54
    {
55
        (new TrackActivityAction(
56
            $this->model,
57
            $this->request_token,
58
            $this->user_id,
59
            $this->route,
60
            $this->model_changes,
61
            $this->description)
62
        )->execute();
63
    }
64
}
65