Conditions | 3 |
Paths | 4 |
Total Lines | 21 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | public static function toString(Closure $closure): string |
||
22 | { |
||
23 | $functionStringValue = ''; |
||
24 | $functionReflection = new ReflectionFunction($closure); |
||
25 | |||
26 | $vars = $functionReflection->getStaticVariables(); |
||
27 | |||
28 | foreach ($vars as $name => $value) { |
||
29 | $value = base64_encode(serialize($value)); |
||
30 | $functionStringValue .= '$'.$name.' = unserialize(base64_decode(\''.$value.'\'));'.PHP_EOL; |
||
31 | } |
||
32 | |||
33 | $file = file($functionReflection->getFileName()); |
||
34 | |||
35 | $lastLine = ($functionReflection->getEndLine() - 1); |
||
36 | |||
37 | for ($codeLine = $functionReflection->getStartLine(); $codeLine < $lastLine; $codeLine++) { |
||
38 | $functionStringValue .= $file[$codeLine]; |
||
39 | } |
||
40 | |||
41 | return $functionStringValue; |
||
42 | } |
||
44 |