Conditions | 4 |
Paths | 3 |
Total Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
35 | 8 | public function convert($value, string $path = '', bool $allowSerializeEmpty = false): AbstractNode |
|
36 | { |
||
37 | 8 | if (null === $value) { |
|
38 | 1 | return NullNode::create(); |
|
39 | } |
||
40 | |||
41 | 7 | $type = gettype($value); |
|
42 | |||
43 | 7 | if (!isset($this->typeMapping[$type])) { |
|
44 | 1 | throw new \InvalidArgumentException( |
|
45 | 1 | sprintf('Type %s is not supported, at path %s', is_object($value) ? get_class($value) : $type, $path) |
|
46 | ); |
||
47 | } |
||
48 | |||
49 | 6 | $node = $this->typeMapping[$type]; |
|
50 | |||
51 | 6 | return $node::create($value, $allowSerializeEmpty); |
|
52 | } |
||
53 | } |
||
54 |