RedirectIfAuthenticated::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace plunner\Http\Middleware;
4
5
use Closure;
6
use Illuminate\Contracts\Auth\Guard;
7
8
class RedirectIfAuthenticated
9
{
10
    /**
11
     * The Guard implementation.
12
     *
13
     * @var Guard
14
     */
15
    protected $auth;
16
17
    /**
18
     * Create a new filter instance.
19
     *
20
     * @param  Guard $auth
21
     */
22
    public function __construct(Guard $auth)
23
    {
24
        $this->auth = $auth;
25
    }
26
27
    /**
28
     * Handle an incoming request.
29
     *
30
     * @param  \Illuminate\Http\Request $request
31
     * @param  \Closure $next
32
     * @return mixed
33
     */
34
    public function handle($request, Closure $next)
35
    {
36
        if ($this->auth->check()) {
37
            return redirect('/');
38
        }
39
40
        return $next($request);
41
    }
42
}
43