RedirectIfAuthenticated   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

1 Method

Rating   Name   Duplication   Size   Complexity  
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
/**
9
 * Class RedirectIfAuthenticated
10
 * @package App\Http\Middleware
11
 */
12
class RedirectIfAuthenticated
13
{
14
    /**
15
     * The Guard implementation.
16
     *
17
     * @var Guard
18
     */
19
    protected $auth;
20
21
    /**
22
     * Create a new filter instance.
23
     * RedirectIfAuthenticated constructor.
24
     * @param Guard $auth
25
     */
26
    public function __construct(Guard $auth)
27
    {
28
        $this->auth = $auth;
29
    }
30
31
    /**
32
     * Handle an incoming request.
33
     *
34
     * @param  \Illuminate\Http\Request $request
35
     * @param  \Closure $next
36
     * @return mixed
37
     */
38
    public function handle($request, Closure $next)
39
    {
40
        if ($this->auth->check()) {
41
            return redirect('/home');
42
        }
43
44
        return $next($request);
45
    }
46
}
47