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

CheckLinkValid::handle()   B

Complexity

Conditions 8
Paths 5

Size

Total Lines 22
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 8

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 22
ccs 12
cts 12
cp 1
rs 8.4444
c 0
b 0
f 0
cc 8
nc 5
nop 2
crap 8
1
<?php
2
3
namespace Linkeys\UrlSigner\Middleware;
4
5
use Closure;
6
use Illuminate\Database\Eloquent\ModelNotFoundException;
7
use Illuminate\Support\Facades\Event;
8
use Linkeys\UrlSigner\Contracts\Models\Link;
9
use Linkeys\UrlSigner\Events\LinkClicked;
10
use Linkeys\UrlSigner\Exceptions\ClickLimit\LinkClickLimitReachedException;
11
use Linkeys\UrlSigner\Exceptions\ClickLimit\LinkGroupClickLimitReachedException;
12
use Linkeys\UrlSigner\Exceptions\Expiry\LinkExpiredException;
13
use Linkeys\UrlSigner\Exceptions\Expiry\LinkGroupExpiredException;
14
use Linkeys\UrlSigner\Exceptions\LinkNotFoundException;
15
use Linkeys\UrlSigner\Support\LinkRepository\LinkRepository;
16
use Symfony\Component\HttpFoundation\Request;
17
18
class CheckLinkValid
19
{
20
21 11
        public function handle(Request $request, Closure $next)
22
    {
23
24 11
        $link = $request->get('link');
25
26 11
        if($link->clickLimitReached()) {
27 1
            throw new LinkClickLimitReachedException;
28
        }
29 10
        if($link->group && $link->group->clickLimitReached()) {
30 1
            throw new LinkGroupClickLimitReachedException;
31
        }
32 9
        if($link->expired()) {
33 3
            throw new LinkExpiredException;
34
        }
35
36 6
        if($link->group && $link->group->expired() && $link->expiry === null) {
37 1
            throw new LinkGroupExpiredException;
38
        }
39
40 5
        Event::dispatch(new LinkClicked($link));
0 ignored issues
show
Bug introduced by
It seems like $link can also be of type null; however, parameter $link of Linkeys\UrlSigner\Events...kClicked::__construct() does only seem to accept Linkeys\UrlSigner\Contracts\Models\Link, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

40
        Event::dispatch(new LinkClicked(/** @scrutinizer ignore-type */ $link));
Loading history...
41
42 5
        return $next($request);
43
    }
44
45
}