Lines
100.00%
6 / 6
Functions and Methods
100.00%
1 / 1
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ActionCallError | 100.00% | 6 / 6 | 100.00% | 1 / 1 | 6 | 100.00% | 1 / 1 | |||
| messageTemplate | 100.00% | 6 / 6 | 100.00% | 1 / 1 | 6 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Contracts\Exception; | |
| 6 | ||
| 7 | enum ActionCallError: string implements ExceptionReason | |
| 8 | { | |
| 9 | case Rejected = 'rejected'; | |
| 10 | case Unreachable = 'unreachable'; | |
| 11 | case TimedOut = 'timed_out'; | |
| 12 | ||
| 13 | case Overloaded = 'overloaded'; | |
| 14 | ||
| 15 | case ActionNameInvalid = 'action_name_invalid'; | |
| 16 | ||
| 17 | public function messageTemplate(): string | |
| 18 | { | |
| 19 | return match ($this) { | |
| 20 | self::Rejected => '{domain}.{action} was rejected by Home Assistant: {detail}', | |
| 21 | self::Unreachable => '{domain}.{action} could not reach Home Assistant: {detail}', | |
| 22 | self::TimedOut => '{domain}.{action} timed out: {detail}', | |
| 23 | self::Overloaded => '{domain}.{action} was refused: {detail}', | |
| 24 | self::ActionNameInvalid => '"{action}" is not an action name; write it as domain.action, such as light.turn_on.', | |
| 25 | }; | |
| 26 | } | |
| 27 | } |