Conditions | 4 |
Paths | 4 |
Total Lines | 13 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | public static function psr2VarExport($var, string $indent=''): string |
||
22 | { |
||
23 | if (is_array($var)) { |
||
24 | $indexed = array_keys($var) === range(0, count($var) - 1); |
||
25 | $r = []; |
||
26 | foreach ($var as $key => $value) { |
||
27 | $r[] = "$indent " |
||
28 | . ($indexed ? '' : self::psr2VarExport($key) . ' => ') |
||
29 | . self::psr2VarExport($value, "$indent "); |
||
30 | } |
||
31 | return "[\n" . implode(",\n", $r) . "\n" . $indent . ']'; |
||
32 | } |
||
33 | return var_export($var, true); |
||
34 | } |
||
54 |