Total Complexity | 6 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | final class ProtocolVersion |
||
16 | { |
||
17 | /** |
||
18 | * Holds the current protocol version |
||
19 | * |
||
20 | * @var string |
||
21 | */ |
||
22 | private $protocolVersion; |
||
23 | |||
24 | private const SUPPORTED_PROTOCOL_VERSIONS = [ |
||
25 | '3.1.1' |
||
26 | ]; |
||
27 | |||
28 | /** |
||
29 | * QoSLevel constructor. |
||
30 | * |
||
31 | * @param string $protocolVersion |
||
32 | * @throws UnacceptableProtocolVersion |
||
33 | */ |
||
34 | 25 | public function __construct(string $protocolVersion) |
|
35 | { |
||
36 | 25 | if (in_array($protocolVersion, self::SUPPORTED_PROTOCOL_VERSIONS, true) === false) { |
|
37 | 1 | throw new UnacceptableProtocolVersion('The specified protocol is invalid'); |
|
38 | } |
||
39 | 24 | $this->protocolVersion = $protocolVersion; |
|
40 | 24 | } |
|
41 | |||
42 | /** |
||
43 | * Gets the current protocol version |
||
44 | * |
||
45 | * @return string |
||
46 | */ |
||
47 | 2 | public function getProtocolVersion(): string |
|
48 | { |
||
49 | 2 | return $this->protocolVersion; |
|
50 | } |
||
51 | |||
52 | /** |
||
53 | * Will return the correct connection identifier for the current protocol |
||
54 | * |
||
55 | * @return string |
||
56 | */ |
||
57 | 4 | public function getProtocolVersionBinaryRepresentation(): string |
|
66 | } |
||
67 | |||
68 | 1 | public function __toString(): string |
|
73 |