Conditions | 3 |
Paths | 4 |
Total Lines | 13 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
48 | 2 | public static function convertBinaryToString(string $binaryRepresentation, bool $applyBase64 = false): string |
|
49 | { |
||
50 | 2 | $output = ''; |
|
51 | 2 | $binaryStringLength = strlen($binaryRepresentation); |
|
52 | 2 | for ($i = 0; $i < $binaryStringLength; $i += 8) { |
|
53 | 2 | $output .= chr((int)base_convert(substr($binaryRepresentation, $i, 8), 2, 10)); |
|
54 | } |
||
55 | |||
56 | 2 | if ($applyBase64 === true) { |
|
57 | 1 | return base64_encode($output); |
|
58 | } |
||
59 | |||
60 | 1 | return $output; |
|
61 | } |
||
63 |