Total Complexity | 5 |
Total Lines | 46 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | final class PacketIdentifier |
||
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 $packetIdentifier; |
||
24 | |||
25 | /** |
||
26 | * QoSLevel constructor. |
||
27 | * |
||
28 | * @param int $packetIdentifier |
||
29 | * @throws \OutOfRangeException |
||
30 | */ |
||
31 | 44 | public function __construct(int $packetIdentifier) |
|
32 | { |
||
33 | 44 | if ($packetIdentifier > 65535 || $packetIdentifier < 1) { |
|
34 | 4 | throw new \OutOfRangeException(sprintf( |
|
35 | 4 | 'The provided packet identifier is invalid. Valid values are 1-65535 (Provided: %d)', |
|
36 | $packetIdentifier |
||
37 | )); |
||
38 | } |
||
39 | |||
40 | 40 | $this->packetIdentifier = $packetIdentifier; |
|
41 | 40 | } |
|
42 | |||
43 | /** |
||
44 | * Gets the current packet identifier value |
||
45 | * |
||
46 | * @return int |
||
47 | */ |
||
48 | 33 | public function getPacketIdentifierValue(): int |
|
51 | } |
||
52 | |||
53 | 1 | public function __toString(): string |
|
58 | } |
||
59 | } |
||
60 |