RedirectIfAuthenticated::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Interfaces\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
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
22
     */
23
    public function __construct(Guard $auth)
24
    {
25
        $this->auth = $auth;
26
    }
27
28
    /**
29
     * Handle an incoming request.
30
     *
31
     * @param  \Illuminate\Http\Request $request
32
     * @param  \Closure $next
33
     * @return mixed
34
     */
35
    public function handle($request, Closure $next)
36
    {
37
        if ($this->auth->check()) {
38
            return redirect('/home');
39
        }
40
41
        return $next($request);
42
    }
43
}
44