IntParser   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B parse() 0 10 5
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