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.

Comment::approve()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace Actuallymab\LaravelComment\Models;
5
6
use Actuallymab\LaravelComment\Contracts\Commentable;
7
use Actuallymab\LaravelComment\HasComments;
8
use Carbon\Carbon;
9
use Illuminate\Database\Eloquent\Builder;
10
use Illuminate\Database\Eloquent\Model;
11
use Illuminate\Database\Eloquent\Relations\MorphTo;
12
13
/**
14
 * @property string $comment
15
 * @property float $rate
16
 * @property boolean $approved
17
 * @property string $commentable_id
18
 * @property string $commentable_type
19
 * @property Model $commentable
20
 * @property string $commented_id
21
 * @property string $commented_type
22
 * @property Model $commented
23
 * @property Carbon $created_at
24
 * @property Carbon $updated_at
25
 */
26
class Comment extends Model implements Commentable
27
{
28
    use HasComments;
29
30
    protected $guarded = [];
31
32
    protected $casts = [
33
        'approved' => 'boolean'
34
    ];
35
36 1
    public function commentable(): MorphTo
37
    {
38 1
        return $this->morphTo();
39
    }
40
41 1
    public function commented(): MorphTo
42
    {
43 1
        return $this->morphTo();
44
    }
45
46 3
    public function scopeApprovedComments(Builder $query): Builder
47
    {
48 3
        return $query->where('approved', true);
49
    }
50
51 3
    public function approve(): self
52
    {
53 3
        $this->approved = true;
54 3
        $this->save();
55
56 3
        return $this;
57
    }
58
}
59