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.

DynamicType::parse()   A
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.3554
c 0
b 0
f 0
cc 5
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
    /**
11
     * Parse a given undefined type value
12
     *
13
     * @param  string $value
14
     * @param  null   $annotation Unused
15
     * @return mixed
16
     */
17
    public function parse($value, $annotation = null)
18
    {
19
        if ('' === $value) return true; // implicit boolean
20
21
        $json = JsonType::jsonDecode($value);
22
23
        if (JSON_ERROR_NONE === json_last_error()) {
24
            return $json;
25
        }
26
        elseif (false !== ($int = filter_var($value, FILTER_VALIDATE_INT))) {
27
            return $int;
28
        }
29
        elseif (false !== ($float = filter_var($value, FILTER_VALIDATE_FLOAT))) {
30
            return $float;
31
        }
32
33
        return $value;
34
    }
35
36
}
37