IntParser::parse()   B
last analyzed

Complexity

Conditions 5
Paths 3

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 7
nc 3
nop 1
1
<?php
2
namespace MetaHydrator\Parser;
3
4
use MetaHydrator\Exception\ParsingException;
5
6
/**
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
        } else if (!is_int($rawValue) && !ctype_digit($rawValue)) {
23
            $this->throw();
24
        } else {
25
            return intval($rawValue);
26
        }
27
    }
28
}
29