Conditions | 6 |
Paths | 6 |
Total Lines | 25 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | public function exportValue(ValueInterface $value) |
||
16 | { |
||
17 | if ($value instanceof ScalarValueInterface) { |
||
18 | return $value->getData(); |
||
19 | } |
||
20 | |||
21 | if ($value instanceof ArrayValueInterface) { |
||
22 | $result = []; |
||
23 | foreach ($value->createChildIterator() as $index => $element) { |
||
24 | $result[$index] = $this->exportValue($element); |
||
25 | } |
||
26 | |||
27 | return $result; |
||
28 | } |
||
29 | |||
30 | if ($value instanceof ObjectValueInterface) { |
||
31 | $result = (object) []; |
||
32 | foreach ($value->createChildIterator() as $name => $property) { |
||
33 | $result->{$name} = $this->exportValue($property); |
||
34 | } |
||
35 | |||
36 | return $result; |
||
37 | } |
||
38 | |||
39 | throw new Exception\UnexpectedValueException($value); |
||
40 | } |
||
42 |