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.

TypeId::isComposite()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 1
1
<?php
2
3
namespace Pinq\Analysis;
4
5
use Pinq\PinqException;
6
7
/**
8
 * Static helper to generate and interpret type identifiers.
9
 *
10
 * @author Elliot Levin <[email protected]>
11
 */
12
final class TypeId
13
{
14
    private function __construct()
15
    {
16
17
    }
18
19
    public static function getObject($class)
20
    {
21
        return 'object:' . $class;
22
    }
23
24
    public static function isObject($id)
25
    {
26
        return strpos($id, 'object:') === 0;
27
    }
28
29
    public static function getClassTypeFromId($objectId)
30
    {
31
        return substr($objectId, strlen('object:'));
32
    }
33
34
    public static function getComposite(array $typeIds)
35
    {
36
        return 'composite<' . implode('|', $typeIds) . '>';
37
    }
38
39
    public static function isComposite($id)
40
    {
41
        return strpos($id, 'composite<') === 0 && $id[strlen($id) - 1] === '>';
42
    }
43
44
    public static function getComposedTypeIdsFromId($compositeId)
45
    {
46
        return explode('|', substr($compositeId, strlen('composite<'), -strlen('>')));
47
    }
48
49
    public static function fromValue($value)
50
    {
51
        switch (gettype($value)) {
52
            case 'string':
53
                return INativeType::TYPE_STRING;
54
55
            case 'integer':
56
                return INativeType::TYPE_INT;
57
58
            case 'boolean':
59
                return INativeType::TYPE_BOOL;
60
61
            case 'double':
62
                return INativeType::TYPE_DOUBLE;
63
64
            case 'NULL':
65
                return INativeType::TYPE_NULL;
66
67
            case 'array':
68
                return INativeType::TYPE_ARRAY;
69
70
            case 'resource':
71
            case 'unknown type':
72
                return INativeType::TYPE_RESOURCE;
73
74
            case 'object':
75
                return self::getObject(get_class($value));
76
        }
77
78
        throw new PinqException('Unknown variable type %s given', gettype($value));
79
    }
80
}
81