| Conditions | 2 |
| Paths | 2 |
| Total Lines | 14 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | 136 | public function returnValue($value): string |
|
| 29 | { |
||
| 30 | // Must be left padded to force even length |
||
| 31 | 136 | $len = strlen($value); |
|
| 32 | 136 | $val = str_pad($value, $len + ($len % 2), '0', \STR_PAD_LEFT); |
|
| 33 | |||
| 34 | // Perform conversion |
||
| 35 | 136 | $val = \hex2bin($val); |
|
| 36 | 136 | if (false === $val) { |
|
| 37 | throw new RuntimeException(sprintf('Unable to convert "%s" to binary', $value)); // @codeCoverageIgnore |
||
| 38 | } |
||
| 39 | |||
| 40 | // Wipe unneeded starting 0 |
||
| 41 | 136 | return ltrim($val, "\0"); |
|
| 42 | } |
||
| 44 |