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 — develop ( 9ecfaa...9ed6b4 )
by Baptiste
07:41
created

Type::determineType()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 24
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 12.7161

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 24
rs 8.5125
ccs 3
cts 7
cp 0.4286
cc 6
eloc 15
nc 6
nop 1
crap 12.7161
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Immutable;
5
6
use Innmind\Immutable\{
7
    Specification\PrimitiveType,
8
    Specification\ClassType,
9
    Specification\VariableType,
10
    Specification\MixedType
11
};
12
13
trait Type
14
{
15
    /**
16
     * Build the approprivate specification for the given type
17
     *
18
     * @param string $type
19
     *
20
     * @return SpecificationInterface
21 226
     */
22
    private function getSpecificationFor(string $type): SpecificationInterface
23 226
    {
24 210
        if (function_exists('is_'.$type)) {
25
            return new PrimitiveType($type);
26
        }
27 104
28 2
        if ($type === 'variable') {
29
            return new VariableType;
30
        }
31 102
32
        if ($type === 'mixed') {
33
            return new MixedType;
34
        }
35
36
        return new ClassType($type);
37
    }
38
39
    /**
40
     * Return the type of the given value
41 8
     *
42
     * @param mixed $value
43 8
     *
44
     * @return string
45
     */
46 8
    private function determineType($value): string
47
    {
48
        $type = gettype($value);
49 8
50 8
        switch ($type) {
51
            case 'object':
52
                return get_class($value);
53
54
            case 'integer':
55
                return 'int';
56
57
            case 'boolean':
58
                return 'bool';
59
60
            case 'NULL':
61
                return 'null';
62
63
            case 'double':
64
                return 'float';
65
66
            default:
67
                return $type;
68
        }
69
    }
70
}
71