Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Link::connect()   B
last analyzed

Complexity

Conditions 5
Paths 3

Size

Total Lines 22
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 11
nc 3
nop 3
dl 0
loc 22
rs 8.6737
c 0
b 0
f 0
1
<?php
2
3
namespace App\Model;
4
5
use App\Classes\Interfaces\Linker;
6
use Illuminate\Support\Collection;
7
use App\Classes\Interfaces\Linkable;
8
use Illuminate\Database\Eloquent\Model;
9
10
/**
11
 * Class Link.
12
 *
13
 * @property string $external
14
 *
15
 * @property Linkable $to
16
 */
17
class Link extends Model
18
{
19
    /**
20
     * The table associated with the model.
21
     *
22
     * @var string
23
     */
24
    protected $table = 'links';
25
26
    /**
27
     * The attributes that are not mass assignable.
28
     *
29
     * @var array
30
     */
31
    protected $guarded = [];
32
33
    /**
34
     * The table date columns, casted to Carbon.
35
     *
36
     * @var array
37
     */
38
    protected $dates = ['created_at', 'updated_at', 'deleted_at'];
39
40
    /**
41
     * @return \Illuminate\Database\Eloquent\Relations\MorphTo|Collection
42
     */
43
    public function from()
44
    {
45
        return $this->morphTo();
46
    }
47
48
    /**
49
     * @return \Illuminate\Database\Eloquent\Relations\MorphTo|Collection|Linkable
50
     */
51
    public function to()
52
    {
53
        return $this->morphTo();
54
    }
55
56
    /**
57
     * @return string
58
     */
59
    public function url()
60
    {
61
        if ($this->isExternal()) {
62
            return $this->external;
63
        }
64
65
        return $this->to->route();
66
    }
67
68
    /**
69
     * @return bool
70
     */
71
    public function isExternal()
72
    {
73
        return $this->external ? true : false;
74
    }
75
76
    /**
77
     * @param Linker $model
78
     * @param Linkable|null $object
79
     * @param string $external
80
     * @return $this
81
     */
82
    public function connect(Linker $model, Linkable $object = null, string $external = '')
83
    {
84
        if ($model && $object) {
85
            $this->setAttribute('from_id', $model->getKey());
86
87
            $this->setAttribute('from_type', $model->getMorphClass());
88
89
            $this->setAttribute('to_id', $object->getKey());
90
91
            $this->setAttribute('to_type', $object->getMorphClass());
92
93
            return $this;
94
        }
95
96
        if ($model && $external) {
97
            $this->setAttribute('from_id', $model->getKey());
98
99
            $this->setAttribute('from_type', $model->getMorphClass());
100
101
            $this->setAttribute('external', $external);
102
103
            return $this;
104
        }
105
    }
106
}
107