Conditions | 5 |
Paths | 4 |
Total Lines | 17 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
20 | 352 | public function hydrate($entity, array $data): object |
|
21 | { |
||
22 | 352 | $relations = $this->relationMap->getRelations(); |
|
23 | 352 | foreach ($data as $k => $v) { |
|
24 | 344 | if ($v instanceof ReferenceInterface && \array_key_exists($k, $relations)) { |
|
25 | 224 | $relation = $relations[$k]; |
|
26 | 224 | $relation->resolve($v, false); |
|
27 | |||
28 | 224 | $entity->{$k} = $v->hasValue() |
|
29 | 80 | ? $relation->collect($v->getValue()) |
|
30 | 184 | : new Promise($relation, $v); |
|
31 | 224 | continue; |
|
32 | } |
||
33 | 336 | $entity->{$k} = $v; |
|
34 | } |
||
35 | |||
36 | 352 | return $entity; |
|
37 | } |
||
63 |