Guardian::restricted()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
namespace EmilMoe\Guardian\Http;
4
5
use Illuminate\Support\Facades\Redirect;
6
use Symfony\Component\HttpKernel\Exception\HttpException;
7
8
class Guardian
9
{
10
    /**
11
     * Method called when user tries to access a page without permission.
12
     *
13
     * @return HttpException|Redirect
14
     */
15
    public static function restricted()
16
    {
17
        return config('guardian.redirect') == null
18
            ? abort(403, 'Unauthorized access.')
19
            : Redirect::to(config('guardian.redirect'));
20
    }
21
}