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.

Approval::scopeOpen()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Victorlap\Approvable;
4
5
use Illuminate\Database\Eloquent\Builder;
6
use Illuminate\Database\Eloquent\Model as Eloquent;
7
use Illuminate\Database\Eloquent\Relations\MorphTo;
8
9
class Approval extends Eloquent
10
{
11
    public $table = 'approvals';
12
13
    protected $casts = ['approved' => 'bool'];
14
15 1
    public function approvable(): MorphTo
16
    {
17 1
        return $this->morphTo();
18
    }
19
20 1
    public function getFieldName(): string
21
    {
22 1
        return $this->key;
23
    }
24
25 1
    public function accept(): void
26
    {
27 1
        $approvable  = $this->approvable;
28 1
        $approvable->withoutApproval();
29 1
        $approvable->{$this->getFieldName()} = $this->value;
30 1
        $approvable->save();
31 1
        $approvable->withApproval();
32
33 1
        $this->approved = true;
34 1
        $this->save();
35 1
    }
36
37 1
    public function reject(): void
38
    {
39 1
        $this->approved = false;
40 1
        $this->save();
41 1
    }
42
43 3
    public function scopeOpen($query): Builder
44
    {
45 3
        return $query->where('approved', null);
46
    }
47
48 3
    public function scopeRejected($query): Builder
49
    {
50 3
        return $query->where('approved', false);
51
    }
52
53 3
    public function scopeAccepted($query): Builder
54
    {
55 3
        return $query->where('approved', true);
56
    }
57
58 1
    public function scopeOfClass($query, $class): Builder
59
    {
60 1
        return $query->where('approvable_type', $class);
61
    }
62
}
63