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::parse()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 10
nc 5
nop 2
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