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 ( 6104e1...48a667 )
by Baptiste
02:19
created

Type   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 73.32%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSpecificationFor() 0 12 3
A determineType() 0 18 4
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
};
11
12
trait Type
13
{
14
    /**
15
     * Build the approprivate specification for the given type
16
     *
17
     * @param string $type
18
     *
19
     * @return SpecificationInterface
20
     */
21 224
    private function getSpecificationFor(string $type): SpecificationInterface
22
    {
23 224
        if (function_exists('is_'.$type)) {
24 208
            return new PrimitiveType($type);
25
        }
26
27 102
        if ($type === 'variable') {
28 2
            return new VariableType;
29
        }
30
31 100
        return new ClassType($type);
32
    }
33
34
    /**
35
     * Return the type of the given value
36
     *
37
     * @param mixed $value
38
     *
39
     * @return string
40
     */
41 8
    private function determineType($value): string
42
    {
43 8
        $type = gettype($value);
44
45
        switch ($type) {
46 8
            case 'object':
47
                return get_class($value);
48
49 8
            case 'integer':
50 8
                return 'int';
51
52
            case 'boolean':
53
                return 'bool';
54
55
            default:
56
                return $type;
57
        }
58
    }
59
}
60