RedirectIfAuthenticated::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 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