Lines
88.88%
8 / 9
Methods
75.00%
3 / 4
Classes
0.00%
0 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| type | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | ||
| describe | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| toMessage | 100.00% | 6 / 6 | 100.00% | 1 / 1 | 1 | ||
| 13 | final readonly class UpsertExposedEntity implements HaCommand | |
| 14 | { | |
| 15 | public function __construct( | |
| 16 | public ExposedEntityAddress $address, | |
| 17 | public ExposedEntityDefinition $definition, | |
| 18 | public ExposedStateChange $change, | |
| 19 | ) {} | |
| 20 | ||
| 21 | public function type(): string | |
| 22 | { | |
| 23 | return 'stewart/entity/upsert'; | |
| 24 | } | |
| 25 | ||
| 26 | public function describe(): string | |
| 27 | { | |
| 28 | return \sprintf('%s %s', $this->type(), $this->address->describe()); | |
| 29 | } | |
| 30 | ||
| 31 | public function toMessage(): array | |
| 32 | { | |
| 33 | return [ | |
| 34 | 'type' => $this->type(), | |
| 35 | ...$this->address->toMessageFields(), | |
| 36 | ...$this->definition->toMessageFields(), | |
| 37 | ...ExposedStateFields::formatStateChange($this->change), | |
| 38 | ]; | |
| 39 | } | |
| 40 | } |