RedirectIfAuthenticated::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 2
eloc 4
nc 2
nop 2
1
<?php namespace App\Http\Middleware;
2
3
use Closure;
4
use Illuminate\Contracts\Auth\Guard;
5
use Illuminate\Http\RedirectResponse;
6
7
class RedirectIfAuthenticated {
8
9
	/**
10
	 * The Guard implementation.
11
	 *
12
	 * @var Guard
13
	 */
14
	protected $auth;
15
16
	/**
17
	 * Create a new filter instance.
18
	 *
19
	 * @param  Guard  $auth
20
	 * @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...
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
		{
38
			return new RedirectResponse(url('/home'));
39
		}
40
41
		return $next($request);
42
	}
43
44
}
45