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