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.

Permissions::check()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
namespace LaravelFlare\Flare\Permissions;
4
5
use LaravelFlare\Flare\Exceptions\PermissionsException;
6
use LaravelFlare\Flare\Contracts\Permissions\Permissionable;
7
8
class Permissions implements Permissionable
9
{
10
    /**
11
     * Checks if the currently Authenticated User
12
     * has access to a given action.
13
     *
14
     * @param string $class
15
     * @param string $action
16
     * 
17
     * @return
18
     */
19
    public static function check($class = null, $action = 'view')
20
    {
21
        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...
22
            return \Auth::user()->is_admin;
23
        }
24
25
        return \Auth::user()->is_admin;
26
    }
27
28
    /**
29
     * Method called when a User attempts to access
30
     * an area of the site or admin which they do 
31
     * not have the permissions to interact with.
32
     *
33
     * This is typically called from the CheckPermissions
34
     * Middleware during a request (see: \LaravelFlare\Flare\Http\Middleware\CheckPermissions::handle())
35
     * and can be used to throw an exception, return a 
36
     * view (abort() etc.) or anything else really.
37
     * 
38
     * @param string $class
39
     * @param string $action
40
     *
41
     * @return mixed
42
     */
43
    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...
44
    {
45
        throw new PermissionsException('Permission denied!');
46
    }
47
}
48