Conditions | 3 |
Paths | 3 |
Total Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 0 |
1 | <?php |
||
20 | private function callback(array $strings) |
||
21 | { |
||
22 | $strTmp = base64_decode($strings[1], true); |
||
23 | |||
24 | if ($strTmp === false) { |
||
25 | return $strings[0]; |
||
26 | } |
||
27 | |||
28 | if (rtrim(base64_encode($strTmp), '=') !== rtrim($strings[1], '=')) { |
||
29 | return $strings[0]; |
||
30 | } |
||
31 | |||
32 | $string = (string)preg_replace_callback( |
||
33 | '/^((?:\x00.)*?)((?:[^\x00].)+)/us', |
||
34 | function ($matches) { |
||
35 | return $matches[1] . '+' . rtrim(base64_encode($matches[2]), '=') . '-'; |
||
36 | }, |
||
37 | $strTmp |
||
38 | ); |
||
39 | |||
40 | return (string)preg_replace('/\x00(.)/us', '$1', $string); |
||
41 | } |
||
42 | |||
43 | } |