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.
Passed
Push — master ( 277531...da2303 )
by Toby
06:21 queued 02:58
created

Link   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 10
eloc 29
dl 0
loc 70
ccs 28
cts 28
cp 1
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
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 53
    public function __construct(array $attributes = [])
43
    {
44 53
        parent::__construct($attributes);
45 53
        $this->table = config('links.tables.links');
46 53
    }
47
48 11
    public function group()
49
    {
50 11
        return $this->belongsTo(Group::class);
51
    }
52
53 53
    public static function boot()
54
    {
55 53
        parent::boot();
56
        self::creating(function ($model) {
57 49
            $model->uuid = $model->uuid ?: resolve(UuidCreator::class)->create();
58 53
        });
59 53
    }
60
61 49
    public function setExpiryAttribute($expiry)
62
    {
63 49
        $normaliser = resolve(NormaliserManagerContract::class);
64 49
        $this->attributes['expiry'] = $normaliser->normalise($expiry);
65 49
    }
66
67 3
    public function getFullUrl()
68
    {
69 3
        $urlParser = resolve(UrlManipulator::class);
70 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...
71 3
        $urlParser->appendQuery([config('links.query_key') => $this->uuid]);
72 3
        return $urlParser->getUrl();
73
    }
74
75 15
    public function clickLimitReached()
76
    {
77 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...
78 11
            return false;
79
        }
80 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...
81
    }
82
83 12
    public function expired()
84
    {
85 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...
86 5
            return false;
87
        }
88 7
        return !(new Carbon($this->expiry))->isFuture();
89
    }
90
91
}