Lines 100.00% 5 / 5
Functions and Methods 100.00% 1 / 1
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
MqttDropReason 100.00% 5 / 5 100.00% 1 / 1 5 100.00% 1 / 1
 describeDrop 100.00% 5 / 5 100.00% 1 / 1 5
1<?php
2
3declare(strict_types=1);
4
5namespace Stewart\Runtime\Model;
6
7enum MqttDropReason: string
8{
9    case Disconnected = 'disconnected';
10    case SendFailed = 'send_failed';
11    case BufferFull = 'buffer_full';
12    case GaveUp = 'gave_up';
13
14    public function describeDrop(): string
15    {
16        return match ($this) {
17            self::Disconnected => 'MQTT message dropped while the server is unreachable',
18            self::SendFailed => 'MQTT message dropped; sending it failed',
19            self::BufferFull => 'MQTT outbound buffer is full; dropped the oldest message',
20            self::GaveUp => 'MQTT message dropped; the server never acknowledged it',
21        };
22    }
23}