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