Lines
100.00%
2 / 2
Functions and Methods
100.00%
1 / 1
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| WorkerSlotCollection | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 1 | 100.00% | 1 / 1 | |||
| requireSlotById | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Runtime\Broker\Collection; | |
| 6 | ||
| 7 | use Stewart\Contracts\Collection\ListCollection; | |
| 8 | use Stewart\Runtime\Broker\WorkerSlot; | |
| 9 | use Stewart\Runtime\Exception\WorkerError; | |
| 10 | use Stewart\Runtime\Exception\WorkerException; | |
| 11 | ||
| 12 | /** @extends ListCollection<WorkerSlot> */ | |
| 13 | final readonly class WorkerSlotCollection extends ListCollection | |
| 14 | { | |
| 15 | /** @throws WorkerException */ | |
| 16 | public function requireSlotById(string $workerId): WorkerSlot | |
| 17 | { | |
| 18 | return $this->findFirstWhere(static fn(WorkerSlot $slot): bool => (string) $slot->workerId === $workerId) | |
| 19 | ?? throw WorkerException::createForReason(WorkerError::Unknown, workerId: $workerId); | |
| 20 | } | |
| 21 | } |