RedirectIfAuthenticated::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 3
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of laravel.su package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
declare(strict_types=1);
10
11
namespace App\Http\Middleware;
12
13
use Closure;
14
use Illuminate\Support\Facades\Auth;
15
16
/**
17
 * Class RedirectIfAuthenticated.
18
 */
19
class RedirectIfAuthenticated
20
{
21
    /**
22
     * Handle an incoming request.
23
     *
24
     * @param  \Illuminate\Http\Request $request
25
     * @param  \Closure                 $next
26
     * @param  string|null              $guard
27
     * @return mixed
28
     */
29
    public function handle($request, Closure $next, $guard = null)
30
    {
31
        if (Auth::guard($guard)->check()) {
32
            return redirect()->route('home');
33
        }
34
35
        return $next($request);
36
    }
37
}
38