RedirectIfAuthenticated   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 54.55%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 36
ccs 6
cts 11
cp 0.5455
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 8 2
1
<?php
2
3
namespace PiFinder\Http\Middleware;
4
5
use Closure;
6
use Illuminate\Contracts\Auth\Guard;
7
use Illuminate\Http\RedirectResponse;
8
9
class RedirectIfAuthenticated
10
{
11
    /**
12
     * The Guard implementation.
13
     *
14
     * @var Guard
15
     */
16
    protected $auth;
17
18
    /**
19
     * Create a new filter instance.
20
     *
21
     * @param Guard $auth
22
     */
23 1
    public function __construct(Guard $auth)
24
    {
25 1
        $this->auth = $auth;
26 1
    }
27
28
    /**
29
     * Handle an incoming request.
30
     *
31
     * @param \Illuminate\Http\Request $request
32
     * @param \Closure                 $next
33
     *
34
     * @return mixed
35
     */
36 1
    public function handle($request, Closure $next)
37
    {
38 1
        if ($this->auth->check()) {
39
            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...
40
        }
41
42 1
        return $next($request);
43
    }
44
}
45