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
Pull Request — master (#65)
by
unknown
01:40
created

DynamicType::getType()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
namespace Minime\Annotations\Types;
4
5
use Minime\Annotations\Interfaces\TypeInterface;
6
7
class DynamicType implements TypeInterface
8
{
9
    /**
10
     * @var TypeInterface
11
     */
12
    private static $instance;
13
14
    public static function getType()
15
    {
16
        if (!isset(self::$instance)) {
17
            self::$instance = new DynamicType();
18
        }
19
20
        return self::$instance;
21
    }
22
23
    /**
24
     * Parse a given undefined type value
25
     *
26
     * @param  string $value
27
     * @param  null   $annotation Unused
28
     * @return mixed
29
     */
30
    public function parse($value, $annotation = null)
31
    {
32
        if ('' === $value) return true; // implicit boolean
33
34
        $json = JsonType::jsonDecode($value);
35
36
        if (JSON_ERROR_NONE === json_last_error()) {
37
            return $json;
38
        }
39
        elseif (false !== ($int = filter_var($value, FILTER_VALIDATE_INT))) {
40
            return $int;
41
        }
42
        elseif (false !== ($float = filter_var($value, FILTER_VALIDATE_FLOAT))) {
43
            return $float;
44
        }
45
46
        return $value;
47
    }
48
49
}
50