Lines
85.71%
6 / 7
Functions and Methods
75.00%
3 / 4
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| FireEvent | 85.71% | 6 / 7 | 75.00% | 3 / 4 | 5.07 | 0.00% | 0 / 1 | |||
| __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% | 4 / 4 | 100.00% | 1 / 1 | 2 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Client\Connection\Command; | |
| 6 | ||
| 7 | use Stewart\Support\Wire\EventPayload; | |
| 8 | ||
| 9 | final readonly class FireEvent implements HaCommand | |
| 10 | { | |
| 11 | public function __construct(public EventPayload $payload) {} | |
| 12 | ||
| 13 | public function type(): string | |
| 14 | { | |
| 15 | return 'fire_event'; | |
| 16 | } | |
| 17 | ||
| 18 | public function describe(): string | |
| 19 | { | |
| 20 | return \sprintf('fire_event %s', $this->payload->eventType); | |
| 21 | } | |
| 22 | ||
| 23 | public function toMessage(): array | |
| 24 | { | |
| 25 | $message = ['type' => $this->type(), 'event_type' => $this->payload->eventType]; | |
| 26 | ||
| 27 | if ($this->payload->data !== []) { | |
| 28 | $message['event_data'] = $this->payload->data; | |
| 29 | } | |
| 30 | ||
| 31 | return $message; | |
| 32 | } | |
| 33 | } |