Lines
0.00%
0 / 8
Functions and Methods
0.00%
0 / 1
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| MqttClientError | 0.00% | 0 / 8 | 0.00% | 0 / 1 | 72 | 0.00% | 0 / 1 | |||
| messageTemplate | 0.00% | 0 / 8 | 0.00% | 0 / 1 | 72 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Mqtt\Exception; | |
| 6 | ||
| 7 | use Stewart\Contracts\Exception\ExceptionReason; | |
| 8 | ||
| 9 | enum MqttClientError: string implements ExceptionReason | |
| 10 | { | |
| 11 | case ConnectionRefused = 'mqtt_connection_refused'; | |
| 12 | case ConnectionLost = 'mqtt_connection_lost'; | |
| 13 | case ConnectionClosed = 'mqtt_connection_closed'; | |
| 14 | case KeepaliveTimedOut = 'mqtt_keepalive_timed_out'; | |
| 15 | case PacketMalformed = 'mqtt_packet_malformed'; | |
| 16 | case PacketUnexpected = 'mqtt_packet_unexpected'; | |
| 17 | case PacketIdsExhausted = 'mqtt_packet_ids_exhausted'; | |
| 18 | ||
| 19 | public function messageTemplate(): string | |
| 20 | { | |
| 21 | return match ($this) { | |
| 22 | self::ConnectionRefused => 'The MQTT server refused the connection: {refusal}.', | |
| 23 | self::ConnectionLost => 'The MQTT connection was lost: {cause}', | |
| 24 | self::ConnectionClosed => 'The MQTT connection is closed.', | |
| 25 | self::KeepaliveTimedOut => 'The MQTT server left a keepalive ping unanswered for {keepalive}.', | |
| 26 | self::PacketMalformed => 'The MQTT server sent a malformed {packetType} packet.', | |
| 27 | self::PacketUnexpected => 'The MQTT server sent an unexpected {packetType} packet.', | |
| 28 | self::PacketIdsExhausted => 'Every MQTT packet identifier is in flight.', | |
| 29 | }; | |
| 30 | } | |
| 31 | } |