| Conditions | 7 |
| Paths | 7 |
| Total Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | public static function exportVariable($var, $indent='') |
||
| 17 | { |
||
| 18 | switch (gettype($var)) { |
||
| 19 | case 'string': |
||
| 20 | return '"' . addcslashes($var, "\\\$\"\r\n\t\v\f") . '"'; |
||
| 21 | |||
| 22 | case 'array': |
||
| 23 | $indexed = array_keys($var) === range(0, count($var) - 1); |
||
| 24 | $r = []; |
||
| 25 | foreach ($var as $key => $value) { |
||
| 26 | $r[] = $indent . ' ' |
||
| 27 | . ($indexed ? '' : self::exportVariable($key) . ' => ') |
||
| 28 | . self::exportVariable($value, $indent . ' '); |
||
| 29 | } |
||
| 30 | return "[\n" . implode(",\n", $r) . "\n" . $indent . "]"; |
||
| 31 | |||
| 32 | case 'boolean': |
||
| 33 | return $var ? 'TRUE' : 'FALSE'; |
||
| 34 | |||
| 35 | default: |
||
| 36 | return var_export($var, true); |
||
| 37 | } |
||
| 38 | } |
||
| 39 | } |
||
| 40 |