StringParser::parse()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 3
eloc 6
nc 3
nop 1
1
<?php
2
namespace MetaHydrator\Parser;
3
4
use MetaHydrator\Exception\ParsingException;
5
6
/**
7
 * Class StringParser
8
 * @package MetaHydrator\Parser
9
 */
10
class StringParser 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) {
21
            return null;
22
        } else if (!is_scalar($rawValue)) {
23
            $this->throw();
24
        }
25
        return strval($rawValue);
26
    }
27
}
28