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 ( 73d557...f5b279 )
by
unknown
01:27
created

ControllerPermissionChecker::permissionCheck()   B

Complexity

Conditions 7
Paths 7

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 8.2222
c 0
b 0
f 0
cc 7
eloc 9
nc 7
nop 2
1
<?php
2
3
class ControllerPermissionChecker extends Controller {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
5
6
    /**
7
     * checks that the url is contains the secret code and is coming from the correct IP address (if not set to wildcard)
8
     * @var array $codesWithIPs
9
     * @var array $code - ID parameter in URL
10
     * @return Boolean
0 ignored issues
show
Documentation introduced by
Should the return type not be boolean|string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
11
     */
12
    public static function permissionCheck($codesWithIPs, $code) {
13
        //with a code you do not have to be logged in ...
14
        if(count($codesWithIPs)) {
15
            $ip = EcommerceCountry::get_ip();
16
            if($code) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $code of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
17
                $testIP = isset($codesWithIPs[$code]) ? $codesWithIPs[$code] : false;
18
                if($testIP) {
19
                    if($testIP === $ip || $testIP === '*') {
20
                        return true;
21
                    }
22
                }
23
            }
24
        }
25
        return Permission::check('ADMIN');
26
    }
27
28
}
29