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.

AddLinkToRequest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 11
dl 0
loc 42
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 12 2
A link() 0 5 1
A __construct() 0 4 1
1
<?php
2
3
4
namespace Linkeys\UrlSigner\Middleware;
5
6
7
use Closure;
8
use Illuminate\Database\Eloquent\ModelNotFoundException;
9
use Linkeys\UrlSigner\Contracts\Models\Link;
10
use Linkeys\UrlSigner\Exceptions\LinkNotFoundException;
11
use Linkeys\UrlSigner\Support\LinkRepository\LinkRepository;
12
use Linkeys\UrlSigner\Support\UrlManipulator\UrlManipulator;
13
use Symfony\Component\HttpFoundation\Request;
14
15
class AddLinkToRequest
16
{
17
18
    /**
19
     * @var LinkRepository
20
     */
21
    private $linkRepository;
22
23 3
    public function __construct(LinkRepository $linkRepository)
24
    {
25
26 3
        $this->linkRepository = $linkRepository;
27 3
    }
28
29 2
    public function handle(Request $request, Closure $next)
30
    {
31
32
        try {
33 2
            $link = $this->link($request);
34 1
        } catch (ModelNotFoundException $e) {
35 1
            throw new LinkNotFoundException;
36
        }
37
38 1
        $request->attributes->add([\Linkeys\UrlSigner\Models\Link::class => $link]);
39
40 1
        return $next($request);
41
    }
42
43
    /**
44
     * Find the link from the request
45
     *
46
     * @param Request $request
47
     *
48
     * @throws ModelNotFoundException
49
     *
50
     * @return Link
51
     */
52 3
    public function link(Request $request)
53
    {
54 3
        $uuid = $request->get(config('links.query_key'));
55
56 3
        return $this->linkRepository->findByUuid($uuid);
57
58
    }
59
}