| Total Complexity | 4 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | final class QoSLevel |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * This field indicates the level of assurance for delivery of an Application Message. Can be 0, 1 or 2 |
||
| 16 | * |
||
| 17 | * 0: At most once delivery (default) |
||
| 18 | * 1: At least once delivery |
||
| 19 | * 2: Exactly once delivery |
||
| 20 | * |
||
| 21 | * @var int |
||
| 22 | */ |
||
| 23 | private $qosLevel = 0; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * QoSLevel constructor. |
||
| 27 | * @param int $QoSLevel |
||
| 28 | * @throws \unreal4u\MQTT\Exceptions\InvalidQoSLevel |
||
| 29 | */ |
||
| 30 | 4 | public function __construct(int $QoSLevel = 0) |
|
| 31 | { |
||
| 32 | 4 | if ($QoSLevel > 2 || $QoSLevel < 0) { |
|
| 33 | 1 | throw new InvalidQoSLevel(sprintf( |
|
| 34 | 1 | 'The provided QoS level is invalid. Valid values are 0, 1 and 2 (Provided: %d)', |
|
| 35 | 1 | $QoSLevel |
|
| 36 | )); |
||
| 37 | } |
||
| 38 | 3 | } |
|
| 39 | |||
| 40 | /** |
||
| 41 | * Gets the current QoS level |
||
| 42 | * |
||
| 43 | * @return int |
||
| 44 | */ |
||
| 45 | 3 | public function getQoSLevel(): int |
|
| 48 | } |
||
| 49 | } |
||
| 50 |