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   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 73.32%

Importance

Changes 0
Metric Value
wmc 10
c 0
b 0
f 0
lcom 0
cbo 4
dl 0
loc 58
rs 10
ccs 11
cts 15
cp 0.7332

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 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