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

Group   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
eloc 18
dl 0
loc 45
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A links() 0 3 1
A setExpiryAttribute() 0 5 1
A expired() 0 6 2
A clickLimitReached() 0 6 2
A __construct() 0 4 1
1
<?php
2
3
namespace Linkeys\UrlSigner\Models;
4
5
use Carbon\Carbon;
6
use Illuminate\Database\Eloquent\Model;
7
use Linkeys\UrlSigner\Contracts\Models\Group as GroupModelContract;
8
use Linkeys\UrlSigner\Support\ExpiryNormaliser\NormaliserManagerContract;
9
10
class Group extends Model implements GroupModelContract
11
{
12
13
    public $fillable = [
14
        'expiry',
15
        'click_limit'
16
    ];
17
18
    protected $dates = [
19
        'expiry'
20
    ];
21
22 32
    public function __construct(array $attributes = [])
23
    {
24 32
        parent::__construct($attributes);
25 32
        $this->table = config('links.tables.groups');
26 32
    }
27
28 7
    public function links()
29
    {
30 7
        return $this->hasMany(Link::class);
31
    }
32
33
34 24
    public function setExpiryAttribute($expiry)
35
    {
36 24
        $normaliser = resolve(NormaliserManagerContract::class);
37 24
        $normalisedExpiry = $normaliser->normalise($expiry);
38 24
        $this->attributes['expiry'] = $normalisedExpiry;
39 24
    }
40
41 10
    public function clickLimitReached()
42
    {
43 10
        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\Group. 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...
44 6
            return false;
45
        }
46 4
        return $this->click_limit <= $this->links->sum('clicks');
47
    }
48
49 6
    public function expired()
50
    {
51 6
        if($this->expiry === null) {
0 ignored issues
show
Bug introduced by
The property expiry does not seem to exist on Linkeys\UrlSigner\Models\Group. 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...
52 1
            return false;
53
        }
54 5
        return !(new Carbon($this->expiry))->isFuture();
55
    }
56
57
}