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.
Passed
Push — master ( 965312...9a1478 )
by
unknown
05:58
created

env()   C

Complexity

Conditions 13
Paths 11

Size

Total Lines 28
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 20
CRAP Score 13

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 13
eloc 19
c 1
b 0
f 0
nc 11
nop 2
dl 0
loc 28
ccs 20
cts 20
cp 1
crap 13
rs 6.6166

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
if (!function_exists('env')) {
3
    /**
4
     * Gets the value of an environment variable.
5
     *
6
     * @param  string $key
7
     * @param  mixed  $default
8
     *
9
     * @return mixed
10
     */
11
    function env($key, $default = null)
12
    {
13 163
        $value = getenv($key);
14
15 163
        if ($value === false) {
16 36
            return value($default);
17
        }
18
19 127
        switch (strtolower($value)) {
20 127
            case 'true':
21 127
            case '(true)':
22 1
                return true;
23 127
            case 'false':
24 127
            case '(false)':
25 125
                return false;
26 3
            case 'empty':
27 3
            case '(empty)':
28 1
                return '';
29 3
            case 'null':
30 3
            case '(null)':
31 1
                return null;
32 2
        }
33
34 2
        if (($valueLength = strlen($value)) > 1 && $value[0] === '"' && $value[$valueLength - 1] === '"') {
35 1
            return substr($value, 1, -1);
36
        }
37
38 2
        return $value;
39
    }
40
}
41
42
if (!function_exists('value')) {
43
    /**
44
     * Return the default value of the given value.
45
     *
46
     * @param  mixed $value
47
     *
48
     * @return mixed
49
     */
50
    function value($value)
51
    {
52 36
        return $value instanceof Closure ? $value() : $value;
53
    }
54
}
55