Authenticate   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

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