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::determineType()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 5.4042

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 5
cts 9
cp 0.5556
rs 9.2
c 0
b 0
f 0
cc 4
eloc 11
nc 4
nop 1
crap 5.4042
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