RedirectIfAuthenticated   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 38
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 9 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