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.

Group   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
eloc 19
c 0
b 0
f 0
dl 0
loc 56
ccs 21
cts 21
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A serializeDate() 0 3 1
A links() 0 3 1
A setExpiryAttribute() 0 5 1
A expired() 0 6 2
A clickLimitReached() 0 6 2
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 33
    public function __construct(array $attributes = [])
23
    {
24 33
        parent::__construct($attributes);
25 33
        $this->table = config('links.tables.groups');
26 33
    }
27
28
    /**
29
     * Prepare a date for array / JSON serialization.
30
     *
31
     * @param  \DateTimeInterface  $date
32
     * @return string
33
     */
34 3
    protected function serializeDate(\DateTimeInterface $date)
35
    {
36 3
        return $date->format('Y-m-d H:i:s');
37
    }
38
39 7
    public function links()
40
    {
41 7
        return $this->hasMany(Link::class);
42
    }
43
44
45 24
    public function setExpiryAttribute($expiry)
46
    {
47 24
        $normaliser = resolve(NormaliserManagerContract::class);
48 24
        $normalisedExpiry = $normaliser->normalise($expiry);
49 24
        $this->attributes['expiry'] = $normalisedExpiry;
50 24
    }
51
52 10
    public function clickLimitReached()
53
    {
54 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...
55 6
            return false;
56
        }
57 4
        return $this->click_limit <= $this->links->sum('clicks');
58
    }
59
60 6
    public function expired()
61
    {
62 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...
63 1
            return false;
64
        }
65 5
        return !(new Carbon($this->expiry))->isFuture();
66
    }
67
68
}