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 ( 036d62...640fb3 )
by Toby
03:52
created

Group::serializeDate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 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 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
}