Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
38 | public static function rleDecode(string $string): string |
||
39 | { |
||
40 | $new = ''; |
||
41 | $last = ''; |
||
42 | $null = chr(0); |
||
43 | $chars = str_split($string); |
||
44 | foreach ($chars as $char) { |
||
45 | if ($last === $null) { |
||
46 | $new .= str_repeat($last, ord($char)); |
||
47 | $last = ''; |
||
48 | continue; |
||
49 | } |
||
50 | $new .= $last; |
||
51 | $last = $char; |
||
52 | } |
||
53 | return $new . $last; |
||
54 | } |
||
88 | } |