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
Branch develop (9ed6b4)
by Baptiste
02:07
created

Type::determineType()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 24
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 6

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 24
ccs 13
cts 13
cp 1
rs 8.5125
cc 6
eloc 15
nc 6
nop 1
crap 6
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
     */
22 228
    private function getSpecificationFor(string $type): SpecificationInterface
23
    {
24 228
        if (function_exists('is_'.$type)) {
25 212
            return new PrimitiveType($type);
26
        }
27
28 106
        if ($type === 'variable') {
29 4
            return new VariableType;
30
        }
31
32 104
        if ($type === 'mixed') {
33 2
            return new MixedType;
34
        }
35
36 104
        return new ClassType($type);
37
    }
38
39
    /**
40
     * Return the type of the given value
41
     *
42
     * @param mixed $value
43
     *
44
     * @return string
45
     */
46 10
    private function determineType($value): string
47
    {
48 10
        $type = gettype($value);
49
50
        switch ($type) {
51 10
            case 'object':
52 2
                return get_class($value);
53
54 10
            case 'integer':
55 10
                return 'int';
56
57 2
            case 'boolean':
58 2
                return 'bool';
59
60 2
            case 'NULL':
61 2
                return 'null';
62
63 2
            case 'double':
64 2
                return 'float';
65
66
            default:
67 2
                return $type;
68
        }
69
    }
70
}
71