Lines 83.33% 5 / 6
Methods 83.33% 5 / 6
Classes 0.00% 0 / 1
Name Lines Methods CRAP
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 listLabelIds 100.00% 1 / 1 100.00% 1 / 1 1
 listAliases 0.00% 0 / 1 0.00% 0 / 1 6
 isHidden 100.00% 1 / 1 100.00% 1 / 1 1
 isDisabled 100.00% 1 / 1 100.00% 1 / 1 1
 hasEntityCategory 100.00% 1 / 1 100.00% 1 / 1 1
12final readonly class RegisteredEntity
13{
14    /**
15     * @param list<LabelId> $labelIds
16     * @param list<EntityAlias>|null $aliases
17     */
18    public function __construct(
19        public EntityId $entityId,
20        public ?DeviceId $deviceId = null,
21        public ?AreaId $areaId = null,
22        #[ListOf(LabelId::class)]
23        public array $labelIds = [],
24        public ?string $name = null,
25        public ?string $entityCategory = null,
26        public ?string $hiddenBy = null,
27        public ?string $disabledBy = null,
28        public ?string $icon = null,
29        // Home Assistant's registry list leaves aliases out, so the mirror holds null.
30        #[ListOf(EntityAlias::class)]
31        public ?array $aliases = null,
32    ) {}
33
34    public function listLabelIds(): LabelIdCollection
35    {
36        return LabelIdCollection::fromList($this->labelIds);
37    }
38
39    public function listAliases(): ?EntityAliasCollection
40    {
41        return $this->aliases === null ? null : EntityAliasCollection::fromList($this->aliases);
42    }
43
44    public function isHidden(): bool
45    {
46        return $this->hiddenBy !== null;
47    }
48
49    public function isDisabled(): bool
50    {
51        return $this->disabledBy !== null;
52    }
53
54    public function hasEntityCategory(): bool
55    {
56        return $this->entityCategory !== null;
57    }
58}