RoutineTrackingUserDeviseJob::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 5
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