Conditions | 2 |
Paths | 2 |
Total Lines | 10 |
Code Lines | 5 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
16 | 11 | public function decodeProtocolHeader(string $data, int $offset = 0): ProtocolHeader |
|
17 | { |
||
18 | 11 | if ((\strlen($data) - $offset) < ProtocolHeader::WIRE_SIZE) { |
|
19 | 2 | throw new InsufficientDataException( |
|
20 | 2 | "Protocol header requires " . ProtocolHeader::WIRE_SIZE |
|
21 | 2 | . " bytes, got " . (\strlen($data) - $offset) . " bytes" |
|
22 | ); |
||
23 | } |
||
24 | |||
25 | 9 | return new ProtocolHeader(\unpack('Preserved/vtype/vreserved', $data, $offset)['type']); |
|
26 | } |
||
28 |