GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 53e94c...ee1db5 )
by Aden
19:49 queued 13:31
created

Permissions::denied()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace LaravelFlare\Flare\Permissions;
4
5
use LaravelFlare\Flare\Contracts\Permissions\Permissionable;
6
7
class Permissions implements Permissionable
8
{
9
    /**
10
     * Checks if the currently Authenticated User
11
     * has access to a given action.
12
     *
13
     * @param string $class
14
     * @param string $action
15
     * 
16
     * @return
17
     */
18
    public static function check($class = null, $action = 'view')
19
    {
20
        if (!$class) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $class of type string|null is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
21
            return \Auth::user()->is_admin;
22
        }
23
24
        if ((new \ReflectionClass(new $class()))->implementsInterface(\LaravelFlare\Flare\Contracts\Permissions\Permissionable::class)) {
25
            return \Auth::user()->can($action, $class);
26
        }
27
28
        return \Auth::user()->is_admin;
29
    }
30
31
    /**
32
     * Method called when a User attempts to access
33
     * an area of the site or admin which they do 
34
     * not have the permissions to interact with.
35
     *
36
     * This is typically called from the CheckPermissions
37
     * Middleware during a request (see: \LaravelFlare\Flare\Http\Middleware\CheckPermissions::handle())
38
     * and can be used to throw an exception, return a 
39
     * view (abort() etc.) or anything else really.
40
     * 
41
     * @param  string $class 
42
     * @param  string $action
43
     * 
44
     * @return [type]        
0 ignored issues
show
Documentation introduced by
The doc-type [type] could not be parsed: Unknown type name "" at position 0. [(view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
45
     */
46
    public static function denied($class = null, $action = 'view')
0 ignored issues
show
Unused Code introduced by
The parameter $class is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $action is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
47
    {
48
        throw new PermissionsException('Permission denied!');
49
    }
50
}
51