Authenticate   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 24
ccs 5
cts 6
cp 0.8333
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 12 4
1
<?php
2
3
namespace App\Http\Middleware;
4
5
use Closure;
6
use Illuminate\Support\Facades\Auth;
7
8
class Authenticate
9
{
10
    /**
11
     * Handle an incoming request.
12
     *
13
     * @param \Illuminate\Http\Request $request
14
     * @param \Closure                 $next
15
     * @param string|null              $guard
16
     *
17
     * @return mixed
18
     */
19 4
    public function handle($request, Closure $next, $guard = null)
20
    {
21 4
        if (Auth::guard($guard)->guest()) {
22 1
            if ($request->ajax() || $request->wantsJson()) {
23
                return response('Unauthorized.', 401);
24
            } else {
25 1
                return redirect()->guest('login');
26
            }
27
        }
28
29 3
        return $next($request);
30
    }
31
}
32