Lines
100.00%
7 / 7
Functions and Methods
100.00%
1 / 1
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| HistoryError | 100.00% | 7 / 7 | 100.00% | 1 / 1 | 7 | 100.00% | 1 / 1 | |||
| messageTemplate | 100.00% | 7 / 7 | 100.00% | 1 / 1 | 7 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Contracts\Exception; | |
| 6 | ||
| 7 | enum HistoryError: string implements ExceptionReason | |
| 8 | { | |
| 9 | case WindowInvalid = 'window_invalid'; | |
| 10 | case RecorderUnavailable = 'recorder_unavailable'; | |
| 11 | case Rejected = 'rejected'; | |
| 12 | case Unreachable = 'unreachable'; | |
| 13 | case TimedOut = 'timed_out'; | |
| 14 | case Overloaded = 'overloaded'; | |
| 15 | ||
| 16 | public function messageTemplate(): string | |
| 17 | { | |
| 18 | return match ($this) { | |
| 19 | self::WindowInvalid => 'A history window must end after it starts, got {startsAt} to {endsAt}.', | |
| 20 | self::RecorderUnavailable => 'History of {entityId} is unavailable because Home Assistant has no history integration loaded.', | |
| 21 | self::Rejected => 'History of {entityId} was rejected by Home Assistant: {detail}', | |
| 22 | self::Unreachable => 'History of {entityId} could not reach Home Assistant: {detail}', | |
| 23 | self::TimedOut => 'History of {entityId} timed out: {detail}', | |
| 24 | self::Overloaded => 'History of {entityId} was refused: {detail}', | |
| 25 | }; | |
| 26 | } | |
| 27 | } |