Lines
100.00%
5 / 5
Methods
100.00%
5 / 5
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| listSubscriptionIdsForWorker | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| listWorkerIds | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| listAppLabels | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| isEmpty | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| 11 | final readonly class SubscriptionRoutes | |
| 12 | { | |
| 13 | /** | |
| 14 | * @param array<int, SubscriptionIdCollection> $subscriptionIdsByWorker | |
| 15 | * @param list<string> $appLabels | |
| 16 | */ | |
| 17 | public function __construct( | |
| 18 | private array $subscriptionIdsByWorker = [], | |
| 19 | private array $appLabels = [], | |
| 20 | ) {} | |
| 21 | ||
| 22 | public function listSubscriptionIdsForWorker(WorkerId $workerId): SubscriptionIdCollection | |
| 23 | { | |
| 24 | return $this->subscriptionIdsByWorker[$workerId->value] ?? SubscriptionIdCollection::empty(); | |
| 25 | } | |
| 26 | ||
| 27 | public function listWorkerIds(): WorkerIdCollection | |
| 28 | { | |
| 29 | return WorkerIdCollection::fromList(array_map(WorkerId::fromInt(...), array_keys($this->subscriptionIdsByWorker))); | |
| 30 | } | |
| 31 | ||
| 32 | /** @return list<string> */ | |
| 33 | public function listAppLabels(): array | |
| 34 | { | |
| 35 | return $this->appLabels; | |
| 36 | } | |
| 37 | ||
| 38 | public function isEmpty(): bool | |
| 39 | { | |
| 40 | return $this->subscriptionIdsByWorker === []; | |
| 41 | } | |
| 42 | } |