Total Complexity | 5 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | <?php |
||
14 | trait PacketIdentifier |
||
15 | { |
||
16 | /** |
||
17 | * The packet identifier variable |
||
18 | * @var PacketIdentifierDataType |
||
19 | */ |
||
20 | private $packetIdentifier = 0; |
||
21 | |||
22 | final public function setPacketIdentifier(PacketIdentifierDataType $packetIdentifier): self |
||
23 | { |
||
24 | $this->packetIdentifier = $packetIdentifier; |
||
25 | return $this; |
||
26 | } |
||
27 | |||
28 | final public function getPacketIdentifier(): int |
||
29 | { |
||
30 | return $this->packetIdentifier->getPacketIdentifierValue(); |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * Returns the binary representation of the packet identifier |
||
35 | * |
||
36 | * @return string |
||
37 | * @throws \OutOfRangeException |
||
38 | */ |
||
39 | final public function getBinaryRepresentation(): string |
||
40 | { |
||
41 | return Utilities::convertNumberToBinaryString($this->packetIdentifier->getPacketIdentifierValue()); |
||
42 | } |
||
43 | |||
44 | final public function generateRandomPacketIdentifier(): self |
||
59 | } |
||
60 | } |
||
61 |