Lines
100.00%
4 / 4
Methods
100.00%
1 / 1
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 4 / 4 | 100.00% | 1 / 1 | 4 | ||
| getPlatform | n/a | 0 / 0 | n/a | 0 / 0 | 0 | ||
| 9 | abstract readonly class ExposedEntityConfig implements ExposureConfig | |
| 10 | { | |
| 11 | private const string ICON_PATTERN = '/\Amdi:[a-z0-9-]+\z/'; | |
| 12 | ||
| 13 | /** @throws ExposureException */ | |
| 14 | public function __construct( | |
| 15 | public ?string $name, | |
| 16 | public ?string $icon, | |
| 17 | public ?EntityCategory $entityCategory, | |
| 18 | public bool $enabledByDefault, | |
| 19 | ) { | |
| 20 | if ($name === '') { | |
| 21 | throw ExposureException::configInvalid('The entity name must not be empty; leave it null to use the device name.'); | |
| 22 | } | |
| 23 | ||
| 24 | if ($icon !== null && preg_match(self::ICON_PATTERN, $icon) !== 1) { | |
| 25 | throw ExposureException::configInvalid(\sprintf('The icon "%s" must look like mdi:thermometer.', $icon)); | |
| 26 | } | |
| 27 | } | |
| 28 | ||
| 29 | abstract public function getPlatform(): ExposedPlatform; | |
| 30 | } |