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