TrustedDevice   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 49
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 1
dl 49
loc 49
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A store() 10 10 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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