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