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