| Conditions | 6 |
| Paths | 8 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 37 | 31 | public function createValue($data, ?PathInterface $path = null): NodeValueInterface |
|
| 38 | { |
||
| 39 | 31 | if (!isset($path)) { |
|
| 40 | 7 | $path = new Path; |
|
| 41 | } |
||
| 42 | 31 | if (null === $data || is_scalar($data)) { |
|
| 43 | 23 | return new NodeScalarValue($data, $path); |
|
| 44 | } |
||
| 45 | |||
| 46 | 10 | if (is_array($data)) { |
|
| 47 | 4 | return new NodeArrayValue($data, $path, $this, $this->valueIteratorFactory); |
|
| 48 | } |
||
| 49 | |||
| 50 | 6 | if ($data instanceof stdClass) { |
|
|
|
|||
| 51 | 4 | return new NodeObjectValue($data, $path, $this, $this->valueIteratorFactory); |
|
| 52 | } |
||
| 53 | |||
| 54 | 2 | throw new Exception\InvalidNodeDataException($data, $path); |
|
| 55 | } |
||
| 57 |