| Conditions | 3 |
| Paths | 4 |
| Total Lines | 18 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 3.009 |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | 5 | public function hydrate($value) |
|
| 24 | { |
||
| 25 | 5 | $collection = $this->getCollectionFromObjectByReference(); |
|
| 26 | 5 | $collectionArray = $collection->toArray(); |
|
| 27 | |||
| 28 | 5 | $toAdd = array_udiff($value, $collectionArray, [$this, 'compareObjects']); |
|
| 29 | 5 | $toRemove = array_udiff($collectionArray, $value, [$this, 'compareObjects']); |
|
| 30 | |||
| 31 | 5 | foreach ($toAdd as $element) { |
|
| 32 | 4 | $collection->add($element); |
|
| 33 | } |
||
| 34 | |||
| 35 | 5 | foreach ($toRemove as $element) { |
|
| 36 | $collection->removeElement($element); |
||
| 37 | } |
||
| 38 | |||
| 39 | 5 | return $collection; |
|
| 40 | } |
||
| 41 | } |
||
| 42 |