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.

Link   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Test Coverage

Coverage 93.55%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 11
eloc 30
c 1
b 0
f 0
dl 0
loc 81
ccs 29
cts 31
cp 0.9355
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A serializeDate() 0 3 1
A __construct() 0 4 1
A expired() 0 6 2
A setExpiryAttribute() 0 4 1
A getFullUrl() 0 6 1
A group() 0 3 1
A clickLimitReached() 0 6 2
A boot() 0 5 2
1
<?php
2
3
namespace Linkeys\UrlSigner\Models;
4
5
use Carbon\Carbon;
6
use Illuminate\Database\Eloquent\Model;
7
use Illuminate\Support\Facades\App;
8
use Linkeys\UrlSigner\Contracts\Models\Link as LinkModelContract;
9
use Linkeys\UrlSigner\Support\ExpiryNormaliser\NormaliserManager;
10
use Linkeys\UrlSigner\Support\ExpiryNormaliser\NormaliserManagerContract;
11
use Linkeys\UrlSigner\Support\ExpiryNormaliser\Normalisers\ExpiryNormaliser;
12
use Linkeys\UrlSigner\Support\ExpiryNormaliser\Normalisers\FromDateTime;
13
use Linkeys\UrlSigner\Support\ExpiryNormaliser\Normalisers\FromInteger;
14
use Linkeys\UrlSigner\Support\ExpiryNormaliser\Normalisers\FromString;
15
use Linkeys\UrlSigner\Support\UrlManipulator\UrlManipulator;
16
use Linkeys\UrlSigner\Support\Uuid\UuidCreator;
17
use Ramsey\Uuid\Uuid;
18
19
class Link extends Model implements LinkModelContract
20
{
21
22
    public $fillable = [
23
        'url',
24
        'data',
25
        'expiry',
26
        'click_limit',
27
    ];
28
29
    protected $casts = [
30
        'data' => 'array',
31
    ];
32
33
    protected $dates = [
34
        'expiry'
35
    ];
36
37
    /**
38
     * @var ExpiryNormaliser
39
     */
40
    protected $normaliser;
41
42
    /**
43
     * Prepare a date for array / JSON serialization.
44
     *
45
     * @param  \DateTimeInterface  $date
46
     * @return string
47
     */
48
    protected function serializeDate(\DateTimeInterface $date)
49
    {
50
        return $date->format('Y-m-d H:i:s');
51
    }
52
53 55
    public function __construct(array $attributes = [])
54
    {
55 55
        parent::__construct($attributes);
56 55
        $this->table = config('links.tables.links');
57 55
    }
58
59 11
    public function group()
60
    {
61 11
        return $this->belongsTo(Group::class);
62
    }
63
64 55
    public static function boot()
65
    {
66 55
        parent::boot();
67 55
        self::creating(function ($model) {
68 51
            $model->uuid = $model->uuid ?: resolve(UuidCreator::class)->create();
69 55
        });
70 55
    }
71
72 51
    public function setExpiryAttribute($expiry)
73
    {
74 51
        $normaliser = resolve(NormaliserManagerContract::class);
75 51
        $this->attributes['expiry'] = $normaliser->normalise($expiry);
76 51
    }
77
78 3
    public function getFullUrl()
79
    {
80 3
        $urlParser = resolve(UrlManipulator::class);
81 3
        $urlParser->setUrl($this->url);
0 ignored issues
show
Bug introduced by
The property url does not seem to exist on Linkeys\UrlSigner\Models\Link. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
82 3
        $urlParser->appendQuery([config('links.query_key') => $this->uuid]);
83 3
        return $urlParser->getUrl();
84
    }
85
86 15
    public function clickLimitReached()
87
    {
88 15
        if($this->click_limit === null) {
0 ignored issues
show
Bug introduced by
The property click_limit does not seem to exist on Linkeys\UrlSigner\Models\Link. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
89 11
            return false;
90
        }
91 4
        return $this->click_limit <= $this->clicks;
0 ignored issues
show
Bug introduced by
The property clicks does not seem to exist on Linkeys\UrlSigner\Models\Link. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
92
    }
93
94 12
    public function expired()
95
    {
96 12
        if($this->expiry === null) {
0 ignored issues
show
Bug introduced by
The property expiry does not seem to exist on Linkeys\UrlSigner\Models\Link. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
97 5
            return false;
98
        }
99 7
        return !(new Carbon($this->expiry))->isFuture();
100
    }
101
102
}