Lines
66.66%
2 / 3
Functions and Methods
66.66%
2 / 3
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Area | 66.66% | 2 / 3 | 66.66% | 2 / 3 | 3.33 | 0.00% | 0 / 1 | |||
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| listLabelIds | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| isNamed | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Contracts\Registry; | |
| 6 | ||
| 7 | use Stewart\Contracts\Registry\Collection\LabelIdCollection; | |
| 8 | use Stewart\Contracts\Wire\ListOf; | |
| 9 | ||
| 10 | final readonly class Area | |
| 11 | { | |
| 12 | /** | |
| 13 | * @param list<string> $aliases | |
| 14 | * @param list<LabelId> $labelIds | |
| 15 | */ | |
| 16 | public function __construct( | |
| 17 | public AreaId $areaId, | |
| 18 | public string $name, | |
| 19 | public ?FloorId $floorId = null, | |
| 20 | #[ListOf('string')] | |
| 21 | public array $aliases = [], | |
| 22 | #[ListOf(LabelId::class)] | |
| 23 | public array $labelIds = [], | |
| 24 | public ?string $icon = null, | |
| 25 | ) {} | |
| 26 | ||
| 27 | public function listLabelIds(): LabelIdCollection | |
| 28 | { | |
| 29 | return LabelIdCollection::fromList($this->labelIds); | |
| 30 | } | |
| 31 | ||
| 32 | public function isNamed(string $name): bool | |
| 33 | { | |
| 34 | return RegistryNames::containsName($name, $this->name, ...$this->aliases); | |
| 35 | } | |
| 36 | } |