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