Completed
Push — 2.0 ( 2d1915 )
by Nicolas
14:43
created

LoggedInMiddleware   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 27
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 namespace Modules\User\Http\Middleware;
2
3
use Modules\Core\Contracts\Authentication;
4
5
class LoggedInMiddleware
6
{
7
    /**
8
     * @var Authentication
9
     */
10
    private $auth;
11
12
    public function __construct(Authentication $auth)
13
    {
14
        $this->auth = $auth;
15
    }
16
17
    /**
18
     * Handle an incoming request.
19
     * @param  \Illuminate\Http\Request $request
20
     * @param  \Closure $next
21
     * @return mixed
22
     */
23
    public function handle($request, \Closure $next)
24
    {
25
        if (! $this->auth->check()) {
26
            return redirect()->guest('auth/login');
27
        }
28
29
        return $next($request);
30
    }
31
}
32