| Conditions | 2 |
| Paths | 2 |
| Total Lines | 20 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 17 | 15 | public function decodeFrameAddress(string $data, int $offset = 0): FrameAddress |
|
| 18 | { |
||
| 19 | 15 | if ((\strlen($data) - $offset) < FrameAddress::WIRE_SIZE) { |
|
| 20 | 2 | throw new InsufficientDataException( |
|
| 21 | 2 | "Frame address requires " . FrameAddress::WIRE_SIZE |
|
| 22 | 2 | . " bytes, got " . (\strlen($data) - $offset) . " bytes" |
|
| 23 | ); |
||
| 24 | } |
||
| 25 | |||
| 26 | [ |
||
| 27 | 13 | 'mac1' => $mac1, 'mac2' => $mac2, 'mac3' => $mac3, 'mac4' => $mac4, 'mac5' => $mac5, 'mac6' => $mac6, |
|
| 28 | 13 | 'flags' => $flags, |
|
| 29 | 13 | 'sequence' => $sequence, |
|
| 30 | 13 | ] = \unpack('C8mac/C6reserved/Cflags/Csequence', $data, $offset); |
|
| 31 | 13 | ||
| 32 | 13 | $target = new MacAddress($mac1, $mac2, $mac3, $mac4, $mac5, $mac6); |
|
| 33 | 13 | $isAckRequired = (bool)($flags & 0x02); |
|
| 34 | 13 | $isResponseRequired = (bool)($flags & 0x01); |
|
| 35 | 13 | ||
| 36 | return new FrameAddress($target, $isAckRequired, $isResponseRequired, $sequence); |
||
| 37 | 13 | } |
|
| 39 |