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
Pull Request — master (#4)
by Nikhil
35:12 queued 24:06
created

Warehouse   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 114
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 74.07%

Importance

Changes 3
Bugs 0 Features 2
Metric Value
wmc 11
c 3
b 0
f 2
lcom 1
cbo 3
dl 0
loc 114
ccs 20
cts 27
cp 0.7407
rs 10

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