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.

AuthMiddleware::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Spatie\LittleGateKeeper;
4
5
use Closure;
6
use Illuminate\Contracts\Config\Repository as Config;
7
use Illuminate\Routing\Redirector;
8
9
class AuthMiddleware
10
{
11
    /**
12
     * @var  \Spatie\LittleGateKeeper\Authenticator
13
     */
14
    protected $authenticator;
15
16
    /**
17
     * @var  \Illuminate\Routing\Redirector
18
     */
19
    protected $redirector;
20
21
    /**
22
     * @var  \Illuminate\Contracts\Config\Repository
23
     */
24
    protected $config;
25
26
    /**
27
     * @param  \Spatie\LittleGateKeeper\Authenticator $authenticator
28
     * @param  \Illuminate\Routing\Redirector $redirector
29
     * @param  \Illuminate\Contracts\Config\Repository $config
30
     */
31
    public function __construct(Authenticator $authenticator, Redirector $redirector, Config $config)
32
    {
33
        $this->authenticator = $authenticator;
34
        $this->redirector    = $redirector;
35
        $this->config        = $config;
36
    }
37
38
    /**
39
     * @param  \Illuminate\Http\Request $request
40
     * @param  \Closure $next
41
     * @return mixed
42
     */
43
    public function handle($request, Closure $next)
44
    {
45
        if (! $this->authenticator->isAuthenticated()) {
46
            return $this->redirector->to($this->config->get('littlegatekeeper.authRoute'));
47
        }
48
49
        return $next($request);
50
    }
51
}
52