Total Complexity | 6 |
Total Lines | 50 |
Duplicated Lines | 0 % |
Coverage | 92.31% |
Changes | 0 |
1 | <?php |
||
12 | final class ProtocolVersion |
||
13 | { |
||
14 | /** |
||
15 | * Holds the current protocol version |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | private $protocolVersion; |
||
20 | |||
21 | const SUPPORTED_PROTOCOL_VERSIONS = [ |
||
22 | '3.1.1' |
||
23 | ]; |
||
24 | |||
25 | /** |
||
26 | * QoSLevel constructor. |
||
27 | * |
||
28 | * @param string $protocolVersion |
||
29 | * @throws \unreal4u\MQTT\Exceptions\Connect\UnacceptableProtocolVersion |
||
30 | */ |
||
31 | 23 | public function __construct(string $protocolVersion) |
|
32 | { |
||
33 | 23 | if (\in_array($protocolVersion, self::SUPPORTED_PROTOCOL_VERSIONS, true) === false) { |
|
34 | 1 | throw new UnacceptableProtocolVersion('The specified protocol is invalid'); |
|
35 | } |
||
36 | 22 | $this->protocolVersion = $protocolVersion; |
|
37 | 22 | } |
|
38 | |||
39 | /** |
||
40 | * Gets the current protocol version |
||
41 | * |
||
42 | * @return string |
||
43 | */ |
||
44 | 2 | public function getProtocolVersion(): string |
|
45 | { |
||
46 | 2 | return $this->protocolVersion; |
|
47 | } |
||
48 | |||
49 | 1 | public function getProtocolVersionBinaryRepresentation(): string { |
|
57 | } |
||
58 | |||
59 | 1 | public function __toString(): string |
|
64 |