GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 321516...5ae950 )
by Nikhil
08:33
created

Warehouse   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 121
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 91.67%

Importance

Changes 4
Bugs 0 Features 3
Metric Value
wmc 11
c 4
b 0
f 3
lcom 1
cbo 4
dl 0
loc 121
rs 10
ccs 22
cts 24
cp 0.9167

7 Methods

Rating   Name   Duplication   Size   Complexity  
A racks() 0 4 1
A guitars() 0 4 1
A addRack() 0 9 2
A addRacks() 0 8 2
A removeRacksNotIn() 0 6 1
A addOrUpdateRack() 0 7 2
A addOrUpdateRacks() 0 8 2
1
<?php
2
3
namespace App;
4
5
use Illuminate\Database\Eloquent;
6
7
class Warehouse extends Eloquent\Model
8
{
9
    use Eloquent\SoftDeletes;
10
11
    /**
12
     * @var array
13
     */
14
    protected $dates = ['deleted_at'];
15
    
16
    /**
17
     * We do not want any timestamps.
18
     *
19
     * @var bool
20
     */
21
    public $timestamps = false;
22
23
    /**
24
     * The attributes that are mass assignable.
25
     *
26
     * @var array
27
     */
28
    protected $fillable = ['name'];
29
30
    /**
31
     * Racks in the warehouse.
32
     *
33
     * @return Eloquent\Relations\HasMany
34
     */
35 7
    public function racks()
36
    {
37 7
        return $this->hasMany(Rack::class);
38
    }
39
40
    /**
41
     * Guitars in the warehouse.
42
     *
43
     * @return Eloquent\Relations\HasManyThrough
44
     */
45
    public function guitars()
46
    {
47
        return $this->hasManyThrough(Guitar::class, Rack::class);
48
    }
49
50
    /**
51
     * Add rack to the warehouse.
52
     *
53
     * @param array|Rack $rack
54
     *
55
     * @return Eloquent\Model
56
     */
57 6
    public function addRack($rack)
58
    {
59 6
        if (is_array($rack)) {
60 3
            $rack = new Rack($rack);
61
        }
62 6
        $this->racks()->save($rack);
63
64 6
        return $this;
65
    }
66
67
    /**
68
     * Add racks to the warehouse.
69
     *
70
     * @param Eloquent\Collection|array $racks
71
     *
72
     * @return $this
73
     */
74 4
    public function addRacks($racks)
75
    {
76 4
        foreach ($racks as $rack) {
77 3
            $this->addRack($rack);
78
        }
79
80 4
        return $this;
81
    }
82
83
    /**
84
     * Remove racks using ids.
85
     *
86
     * @param $ids
87
     *
88
     * @return $this
89
     */
90 2
    public function removeRacksNotIn($ids)
91
    {
92 2
        $this->racks()->whereNotIn('id', $ids)->delete();
93
94 2
        return $this;
95
    }
96
97
    /**
98
     * Add or Update Racks.
99
     *
100
     * @param $rack
101
     *
102
     * @return $this
103
     */
104 3
    public function addOrUpdateRack($rack)
105
    {
106 3
        (array_has($rack, 'id')) ?
107 3
            $this->racks()->find($rack['id'])->update($rack) : $this->addRack($rack);
108
109 3
        return $this;
110
    }
111
112
    /**
113
     * Add or update the racks.
114
     *
115
     * @param $racks
116
     *
117
     * @return $this
118
     */
119 1
    public function addOrUpdateRacks($racks)
120
    {
121 1
        foreach ($racks as $rack) {
122 1
            $this->addOrUpdateRack($rack);
123
        }
124
125 1
        return $this;
126
    }
127
}
128