Lines
100.00%
4 / 4
Functions and Methods
100.00%
1 / 1
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| DomainCatalog | 100.00% | 4 / 4 | 100.00% | 1 / 1 | 1 | 100.00% | 1 / 1 | |||
| getTraitsForDomain | 100.00% | 4 / 4 | 100.00% | 1 / 1 | 1 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Codegen\Model; | |
| 6 | ||
| 7 | final readonly class DomainCatalog | |
| 8 | { | |
| 9 | // Fixed, not inferred: a light that is off in every snapshot still needs isOn(). | |
| 10 | private const array ON_OFF = [ | |
| 11 | 'automation', 'binary_sensor', 'fan', 'group', 'humidifier', 'input_boolean', | |
| 12 | 'light', 'remote', 'script', 'siren', 'switch', 'update', | |
| 13 | ]; | |
| 14 | ||
| 15 | private const array NUMERIC = ['counter', 'input_number', 'number', 'sensor']; | |
| 16 | ||
| 17 | public function getTraitsForDomain(string $domain): DomainTraits | |
| 18 | { | |
| 19 | return new DomainTraits( | |
| 20 | onOff: \in_array($domain, self::ON_OFF, true), | |
| 21 | numeric: \in_array($domain, self::NUMERIC, true), | |
| 22 | ); | |
| 23 | } | |
| 24 | } |