RoutineTrackingUserDeviseJob   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 39
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
A handle() 0 11 1
1
<?php
2
3
namespace Gamer\Jobs;
4
5
use Illuminate\Bus\Queueable;
6
use Illuminate\Queue\SerializesModels;
7
use Illuminate\Queue\InteractsWithQueue;
8
use Illuminate\Contracts\Queue\ShouldQueue;
9
use Illuminate\Foundation\Bus\Dispatchable;
10
11
use Gamer\Models\Customer;
12
use Log;
13
14
class RoutineTrackingUserDeviseJob implements ShouldQueue
15
{
16
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
17
18
    protected $customer, $trackingType, $trackingData, $timestamp, $íp;
19
20
    /**
21
     * Create a new job instance.
22
     *
23
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
24
     */
25
    public function __construct(Customer $customer, $trackingType, $trackingData, $timestamp = false, $ip = false)
26
    {
27
        $this->customer = $customer;
28
        $this->trackingType = $trackingType;
29
        $this->trackingData = $trackingData;
30
        if (!$timestamp) { $timestamp = time();
31
        }
32
        $this->timestamp = $timestamp;
33
        $this->ip = $ip;
0 ignored issues
show
Bug introduced by
The property ip does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
34
    }
35
36
    /**
37
     * Execute the job.
38
     *
39
     * @return void
40
     */
41
    public function handle()
42
    {
43
        $this->customer->tracking->create(
44
            TrackingType::createToTracking(
45
                $this->trackingType,
46
                $this->trackingData,
47
                $this->timestamp,
48
                $this->ip
49
            )
50
        );
51
    }
52
}
53