Conditions | 3 |
Paths | 4 |
Total Lines | 13 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
35 | 2 | public static function convertBinaryToString(string $binaryRepresentation, bool $applyBase64 = false): string |
|
36 | { |
||
37 | 2 | $output = ''; |
|
38 | 2 | $binaryStringLength = \strlen($binaryRepresentation); |
|
39 | 2 | for ($i = 0; $i < $binaryStringLength; $i += 8) { |
|
40 | 2 | $output .= \chr((int)base_convert(substr($binaryRepresentation, $i, 8), 2, 10)); |
|
41 | } |
||
42 | |||
43 | 2 | if ($applyBase64 === true) { |
|
44 | 1 | return base64_encode($output); |
|
45 | } |
||
46 | |||
47 | 1 | return $output; |
|
48 | } |
||
50 |