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   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 10
c 0
b 0
f 0
lcom 0
cbo 4
dl 0
loc 58
ccs 21
cts 21
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSpecificationFor() 0 16 4
B determineType() 0 24 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