Conditions | 2 |
Paths | 2 |
Total Lines | 12 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
27 | 3 | public static function convertToBinaryRepresentation(string $rawString): string |
|
28 | { |
||
29 | 3 | $out = ''; |
|
30 | 3 | $strLength = strlen($rawString); |
|
31 | 3 | for ($a = 0; $a < $strLength; $a++) { |
|
32 | 3 | $dec = ord($rawString[$a]); //determine symbol ASCII-code |
|
33 | //convert to binary representation and add leading zeros |
||
34 | 3 | $bin = sprintf('%08d', base_convert((string)$dec, 10, 2)); |
|
35 | 3 | $out .= $bin; |
|
36 | } |
||
37 | |||
38 | 3 | return $out; |
|
39 | } |
||
63 |