| Conditions | 5 |
| Paths | 4 |
| Total Lines | 23 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | public function replace(FinalItem $finalShard): void |
||
| 27 | { |
||
| 28 | /** @var Item $shard */ |
||
| 29 | $list = $this->list; |
||
| 30 | $listUuid = []; |
||
| 31 | foreach ($list as $key => $shard) { |
||
| 32 | if ($shard instanceof FinalItem) { |
||
| 33 | continue; |
||
| 34 | } |
||
| 35 | $listUuid[] = $shard->getUuid()->getValue(); |
||
| 36 | if ($shard->getUuid()->equal($finalShard->getUuid()) |
||
| 37 | && $shard->getProfile()->equal($finalShard->getProfile())) { |
||
| 38 | $list[$key] = $finalShard; |
||
| 39 | $this->list = $list; |
||
| 40 | return; |
||
| 41 | } |
||
| 42 | } |
||
| 43 | |||
| 44 | throw new InvalidUuidComparisonOnReplaceException( |
||
| 45 | sprintf( |
||
| 46 | 'Could not find initial shard by uuid %s in given collection: %s', |
||
| 47 | $finalShard->getUuid()->getValue(), |
||
| 48 | join(',', $listUuid) |
||
| 49 | ) |
||
| 73 |