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 ( f46a23...825633 )
by Baptiste
04:48
created

Type::determine()   A

Complexity

Conditions 6
Paths 6

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 6

Importance

Changes 0
Metric Value
cc 6
eloc 14
nc 6
nop 1
dl 0
loc 22
ccs 14
cts 14
cp 1
crap 6
rs 9.2222
c 0
b 0
f 0
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
final class Type
14
{
15
    /**
16
     * Build the appropriate specification for the given type
17
     *
18
     * @param string $type
19
     *
20
     * @return SpecificationInterface
21
     */
22 446
    public static function of(string $type): SpecificationInterface
23
    {
24 446
        if (\function_exists('is_'.$type)) {
25 410
            return new PrimitiveType($type);
26
        }
27
28 200
        if ($type === 'variable') {
29 4
            return new VariableType;
30
        }
31
32 198
        if ($type === 'mixed') {
33 2
            return new MixedType;
34
        }
35
36 198
        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 16
    public static function determine($value): string
47
    {
48 16
        $type = \gettype($value);
49
50 16
        switch ($type) {
51 16
            case 'object':
52 2
                return \get_class($value);
53
54 16
            case 'integer':
55 16
                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