| Conditions | 6 |
| Paths | 8 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | 31 | public function createValue($data, ?PathInterface $path = null): NodeValueInterface |
|
| 29 | { |
||
| 30 | 31 | if (!isset($path)) { |
|
| 31 | 7 | $path = new Path; |
|
| 32 | } |
||
| 33 | 31 | if (null === $data || is_scalar($data)) { |
|
| 34 | 23 | return new NodeScalarValue($data, $path); |
|
| 35 | } |
||
| 36 | |||
| 37 | 10 | if (is_array($data)) { |
|
| 38 | 4 | return new NodeArrayValue($data, $path, $this); |
|
| 39 | } |
||
| 40 | |||
| 41 | 6 | if ($data instanceof stdClass) { |
|
| 42 | 4 | return new NodeObjectValue($data, $path, $this); |
|
| 43 | } |
||
| 44 | |||
| 45 | 2 | throw new Exception\InvalidNodeDataException($data, $path); |
|
| 46 | } |
||
| 48 |