Conditions | 7 |
Paths | 9 |
Total Lines | 23 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 7 |
Changes | 0 |
1 | <?php |
||
22 | 1 | protected function loadObject($object, array $data, array $mapping, array $mappingRelation = []) |
|
23 | { |
||
24 | 1 | foreach ($mapping as $objectPath => $arrayPath) { |
|
25 | 1 | if (!is_array($arrayPath)) { |
|
26 | 1 | $propertyAccesorPath = substr($arrayPath, 1); |
|
27 | 1 | if (false === strpos($arrayPath, '@')) { |
|
28 | 1 | $this->accessor->setValue($object, $objectPath, $arrayPath); |
|
29 | 1 | } elseif ($this->accessor->isReadable($data, $propertyAccesorPath)) { |
|
30 | 1 | $this->accessor->setValue($object, $objectPath, $this->accessor->getValue($data, $propertyAccesorPath)); |
|
31 | } |
||
32 | } |
||
33 | |||
34 | 1 | if (isset($mappingRelation[$objectPath]) && array_key_exists($objectPath, $data)) { |
|
35 | 1 | $classRelation = $mappingRelation[$objectPath]; |
|
36 | 1 | $this->accessor->setValue( |
|
37 | 1 | $object, |
|
38 | 1 | $objectPath, |
|
39 | 1 | $this->loadObject(new $classRelation(), $data[$objectPath], $arrayPath) |
|
40 | ); |
||
41 | } |
||
42 | } |
||
43 | |||
44 | 1 | return $object; |
|
45 | } |
||
47 |