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   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 43
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A handle() 0 8 2
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