RedirectIfAuthenticated   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 37
c 1
b 0
f 0
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
	 */
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('/home'));
0 ignored issues
show
Bug introduced by
It seems like url('/home') targeting url() can also be of type object<Illuminate\Contracts\Routing\UrlGenerator>; however, Symfony\Component\HttpFo...Response::__construct() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
38
		}
39
40
		return $next($request);
41
	}
42
43
}
44