Code Duplication    Length = 19-19 lines in 2 locations

src/Parser/FloatParser.php 1 location

@@ 9-27 (lines=19) @@
6
/**
7
 * An implementation of ParserInterface used to parse a float value.
8
 */
9
class FloatParser extends AbstractParser
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

src/Parser/IntParser.php 1 location

@@ 10-28 (lines=19) @@
7
 * Class IntParser
8
 * @package MetaHydrator\Parser
9
 */
10
class IntParser extends AbstractParser
11
{
12
    /**
13
     * @param $rawValue
14
     * @return mixed
15
     *
16
     * @throws ParsingException
17
     */
18
    public function parse($rawValue)
19
    {
20
        if ($rawValue === null || $rawValue === '') {
21
            return null;
22
        }
23
        if (!is_int($rawValue) && !ctype_digit($rawValue)) {
24
            $this->throw();
25
        }
26
        return intval($rawValue);
27
    }
28
}
29