Authenticate   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 37
ccs 0
cts 15
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handle() 0 6 1
A authenticate() 0 8 2
1
<?php
2
3
namespace Sco\Admin\Http\Middleware;
4
5
use Closure;
6
use Auth;
7
use Sco\Admin\Exceptions\AuthenticationException;
8
9
class Authenticate
10
{
11
    public function __construct()
12
    {
13
    }
14
15
    /**
16
     * Handle an incoming request.
17
     *
18
     * @param  \Illuminate\Http\Request $request
19
     * @param  \Closure $next
20
     *
21
     * @return mixed
22
     * @throws \Sco\Admin\Exceptions\AuthenticationException
23
     */
24
    public function handle($request, Closure $next)
25
    {
26
        $this->authenticate();
27
28
        return $next($request);
29
    }
30
31
    /**
32
     * Determine if the user is logged in to any of the given guards.
33
     *
34
     * @return mixed
35
     * @throws \Sco\Admin\Exceptions\AuthenticationException
36
     */
37
    protected function authenticate()
38
    {
39
        if (Auth::check()) {
40
            return Auth::user();
41
        }
42
43
        throw new AuthenticationException();
44
    }
45
}
46