Completed
Push — 1.x ( 2692eb...201d44 )
by Dorian
12s
created

FloatParser::parse()   B

Complexity

Conditions 6
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 10
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 10
loc 10
rs 8.8571
c 1
b 0
f 1
cc 6
eloc 6
nc 3
nop 1
1
<?php
2
namespace MetaHydrator\Parser;
3
4
use MetaHydrator\Exception\ParsingException;
5
6
/**
7
 * An implementation of ParserInterface used to parse a float value.
8
 */
9 View Code Duplication
class FloatParser extends AbstractParser
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11
    /**
12
     * @param $rawValue
13
     * @return float|null
14
     *
15
     * @throws ParsingException
16
     */
17
    public function parse($rawValue)
18
    {
19
        if ($rawValue === null || $rawValue === '') {
20
            return null;
21
        }
22
        if(!is_float($rawValue) && !is_int($rawValue) && !is_numeric($rawValue)) {
23
            $this->throw();
24
        }
25
        return floatval($rawValue);
26
    }
27
}
28