TrustedDevice::store()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
dl 10
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 2
1
<?php
2
3
namespace App\Models;
4
5
/**
6
 * Class TrustedDevice.
7
 */
8 View Code Duplication
class TrustedDevice extends ChocolateyModel
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    /**
11
     * Disable Timestamps.
12
     *
13
     * @var bool
14
     */
15
    public $timestamps = false;
16
17
    /**
18
     * The table associated with the model.
19
     *
20
     * @var string
21
     */
22
    protected $table = 'chocolatey_users_security_trusted';
23
24
    /**
25
     * Primary Key of the Table.
26
     *
27
     * @var string
28
     */
29
    protected $primaryKey = 'id';
30
31
    /**
32
     * The attributes excluded from the model's JSON form.
33
     *
34
     * @var array
35
     */
36
    protected $hidden = ['id'];
37
38
    /**
39
     * Store a new TrustedDevice.
40
     *
41
     * @param int    $userId
42
     * @param string $ipAddress
43
     *
44
     * @return TrustedDevice
45
     */
46
    public function store(int $userId, string $ipAddress): TrustedDevice
47
    {
48
        $this->attributes['user_id'] = $userId;
49
        $this->attributes['ip_address'] = $ipAddress;
50
        $this->timestamps = false;
51
52
        $this->save();
53
54
        return $this;
55
    }
56
}
57