Total Complexity | 9 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
11 | final class Crates extends ImmutableCollection |
||
12 | { |
||
13 | use Purging; |
||
14 | |||
15 | public function __construct(Crate ...$crates) |
||
18 | } |
||
19 | |||
20 | public function current(): Crate |
||
23 | } |
||
24 | |||
25 | public function after(Push $push): self |
||
26 | { |
||
27 | $crates = $this->items(); |
||
28 | foreach ($this as $i => $crate) { |
||
29 | if ($crate->id() === $push->crateId()) { |
||
30 | $crates[$i] = $crate->after($push); |
||
31 | break; |
||
32 | } |
||
33 | } |
||
34 | return $this->newCopy($crates); |
||
|
|||
35 | } |
||
36 | |||
37 | public function withId(string $id): Crate |
||
38 | { |
||
39 | foreach ($this as $crate) { |
||
40 | if ($crate->id() === $id) { |
||
41 | return $crate; |
||
42 | } |
||
43 | } |
||
44 | throw new RuntimeException("No crate with id $id"); |
||
45 | } |
||
46 | |||
47 | public function __toString(): string |
||
50 | } |
||
51 | } |
||
52 |