Lines 75.00% 3 / 4
Methods 75.00% 3 / 4
Classes 0.00% 0 / 1
Name Lines Methods CRAP
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 getDisplayName 100.00% 1 / 1 100.00% 1 / 1 1
 listLabelIds 0.00% 0 / 1 0.00% 0 / 1 2
 isDisabled 100.00% 1 / 1 100.00% 1 / 1 1
10final readonly class Device
11{
12    /** @param list<LabelId> $labelIds */
13    public function __construct(
14        public DeviceId $deviceId,
15        public ?string $name = null,
16        public ?string $nameByUser = null,
17        public ?AreaId $areaId = null,
18        #[ListOf(LabelId::class)]
19        public array $labelIds = [],
20        public ?string $manufacturer = null,
21        public ?string $model = null,
22        public ?string $disabledBy = null,
23    ) {}
24
25    public function getDisplayName(): ?string
26    {
27        return $this->nameByUser ?? $this->name;
28    }
29
30    public function listLabelIds(): LabelIdCollection
31    {
32        return LabelIdCollection::fromList($this->labelIds);
33    }
34
35    public function isDisabled(): bool
36    {
37        return $this->disabledBy !== null;
38    }
39}