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.

FlareAuthenticate   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 12 3
1
<?php
2
3
namespace LaravelFlare\Flare\Http\Middleware;
4
5
use Closure;
6
use Illuminate\Http\Request;
7
use Illuminate\Contracts\Auth\Guard;
8
9
class FlareAuthenticate
10
{
11
    /**
12
     * The Guard implementation.
13
     *
14
     * @var Guard
15
     */
16
    protected $auth;
17
18
    /**
19
     * Create a new filter instance.
20
     *
21
     * @param Guard $auth
22
     */
23
    public function __construct(Guard $auth)
24
    {
25
        $this->auth = $auth;
26
    }
27
28
    /**
29
     * Handle an incoming request.
30
     *
31
     * @param \Illuminate\Http\Request $request
32
     * @param \Closure                 $next
33
     *
34
     * @return mixed
35
     */
36
    public function handle(Request $request, Closure $next)
37
    {
38
        if ($this->auth->guest()) {
39
            if ($request->ajax()) {
40
                return response('Unauthorized.', 401);
41
            }
42
43
            return redirect()->guest(\Flare::adminUrl('login'));
44
        }
45
46
        return $next($request);
47
    }
48
}
49