Lines
0.00%
0 / 6
Functions and Methods
0.00%
0 / 1
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| MqttError | 0.00% | 0 / 6 | 0.00% | 0 / 1 | 42 | 0.00% | 0 / 1 | |||
| messageTemplate | 0.00% | 0 / 6 | 0.00% | 0 / 1 | 42 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Contracts\Exception; | |
| 6 | ||
| 7 | enum MqttError: string implements ExceptionReason | |
| 8 | { | |
| 9 | case TopicInvalid = 'mqtt_topic_invalid'; | |
| 10 | case PayloadUnencodable = 'mqtt_payload_unencodable'; | |
| 11 | case PayloadNotJson = 'mqtt_payload_not_json'; | |
| 12 | case NotConfigured = 'mqtt_not_configured'; | |
| 13 | case PublishFailed = 'mqtt_publish_failed'; | |
| 14 | ||
| 15 | public function messageTemplate(): string | |
| 16 | { | |
| 17 | return match ($this) { | |
| 18 | self::TopicInvalid => 'MQTT topic {topic} must be non-empty UTF-8, free of +, # and NUL characters.', | |
| 19 | self::PayloadUnencodable => 'MQTT payload for {topic} cannot be encoded as JSON: {cause}', | |
| 20 | self::PayloadNotJson => 'MQTT payload on {topic} is not valid JSON: {cause}', | |
| 21 | self::NotConfigured => 'MQTT is not configured; set mqtt.url in stewart.yaml or STEWART_MQTT__URL in .env.', | |
| 22 | self::PublishFailed => 'Could not hand the MQTT message for {topic} to the broker: {cause}', | |
| 23 | }; | |
| 24 | } | |
| 25 | } |