Lines
85.71%
6 / 7
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% | 4 / 4 | 100.00% | 1 / 1 | 2 | ||
| 10 | final readonly class AnswerComponentCommand implements HaCommand | |
| 11 | { | |
| 12 | public function __construct(public ComponentCommandAnswer $answer) {} | |
| 13 | ||
| 14 | public function type(): string | |
| 15 | { | |
| 16 | return 'stewart/command/result'; | |
| 17 | } | |
| 18 | ||
| 19 | public function describe(): string | |
| 20 | { | |
| 21 | return \sprintf('%s %s', $this->type(), $this->answer->commandId); | |
| 22 | } | |
| 23 | ||
| 24 | public function toMessage(): array | |
| 25 | { | |
| 26 | $message = ['type' => $this->type(), 'command_id' => $this->answer->commandId, 'ok' => $this->answer->accepted]; | |
| 27 | ||
| 28 | if ($this->answer->message !== null) { | |
| 29 | $message['message'] = $this->answer->message; | |
| 30 | } | |
| 31 | ||
| 32 | return $message; | |
| 33 | } | |
| 34 | } |