RedirectIfAuthenticated   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 77.78%

Importance

Changes 0
Metric Value
wmc 5
eloc 11
c 0
b 0
f 0
dl 0
loc 25
ccs 7
cts 9
cp 0.7778
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 15 5
1
<?php
2
3
namespace App\Http\Middleware;
4
5
use Closure;
6
use Facades\App\Services\WhichPortal;
7
use Illuminate\Support\Facades\Auth;
8
9
class RedirectIfAuthenticated
10
{
11
    /**
12
     * Handle an incoming request.
13
     *
14
     * @param  \Illuminate\Http\Request  $request
15
     * @param  \Closure  $next
16
     * @param  string|null  $guard
17
     * @return mixed
18 10
     */
19
    public function handle($request, Closure $next, $guard = null)
20 10
    {
21 10
        if (Auth::guard($guard)->check()) {
22 1
            if (Auth::user()->isAdmin()) {
23
                return redirect(backpack_url(''));
0 ignored issues
show
Bug introduced by
The function backpack_url was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
                return redirect(/** @scrutinizer ignore-call */ backpack_url(''));
Loading history...
Bug introduced by
The function redirect was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
                return /** @scrutinizer ignore-call */ redirect(backpack_url(''));
Loading history...
24 1
            } elseif (WhichPortal::isManagerPortal()) {
25 1
                return redirect(route('manager.home'));
0 ignored issues
show
Bug introduced by
The function route was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
                return redirect(/** @scrutinizer ignore-call */ route('manager.home'));
Loading history...
26
            } elseif (WhichPortal::isHrPortal()) {
27
                return route('hr_advisor.home');
28
            } else {
29
                return redirect(route('home'));
30
            }
31 9
        }
32
33
        return $next($request);
34
    }
35
}
36