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

FloatType   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 34
c 0
b 0
f 0
wmc 4
cbo 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getType() 0 8 2
A parse() 0 8 2
1
<?php
2
3
namespace Minime\Annotations\Types;
4
5
use Minime\Annotations\Interfaces\TypeInterface;
6
use Minime\Annotations\ParserException;
7
8
class FloatType implements TypeInterface
9
{
10
    /**
11
     * @var TypeInterface
12
     */
13
    private static $instance;
14
15
    public static function getType()
16
    {
17
        if (!isset(self::$instance)) {
18
            self::$instance = new FloatType();
19
        }
20
21
        return self::$instance;
22
    }
23
24
    /**
25
     * Filter a value to be a Float
26
     *
27
     * @param  string                              $value
28
     * @param  null                                $annotation Unused
29
     * @throws \Minime\Annotations\ParserException
30
     * @return float
31
     */
32
    public function parse($value, $annotation = null)
33
    {
34
        if (false === ($value = filter_var($value, FILTER_VALIDATE_FLOAT))) {
35
            throw new ParserException("Raw value must be float. Invalid value '{$value}' given.");
36
        }
37
38
        return $value;
39
    }
40
41
}
42