| Conditions | 5 |
| Paths | 1 |
| Total Lines | 18 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | 4 | private function generateDiff(EntityInterface $leftEntity, EntityInterface $rightEntity): ValueObjectMap |
|
| 24 | { |
||
| 25 | 4 | return ValueObjectMap::forEntity($leftEntity, array_reduce( |
|
| 26 | 4 | $leftEntity->getEntityType()->getAttributes()->toArray(), |
|
| 27 | 4 | function (array $diff, AttributeInterface $attribute) use ($leftEntity, $rightEntity): array { |
|
| 28 | 4 | $attrName = $attribute->getName(); |
|
| 29 | 4 | if ($rightEntity->has($attrName) && $leftEntity->has($attrName)) { |
|
| 30 | 4 | if (!$leftEntity->get($attrName)->equals($rightEntity->get($attrName))) { |
|
| 31 | 3 | $diff[$attrName] = $leftEntity->get($attrName); |
|
| 32 | } |
||
| 33 | 1 | } elseif ($leftEntity->has($attrName)) { |
|
| 34 | 1 | $diff[$attrName] = $leftEntity->get($attrName); |
|
| 35 | } |
||
| 36 | 4 | return $diff; |
|
| 37 | 4 | }, |
|
| 38 | 4 | [] |
|
| 39 | )); |
||
| 40 | } |
||
| 41 | } |
||
| 42 |