| 1 | <?php |
||
| 7 | class Util |
||
| 8 | { |
||
| 9 | public static function varExport($var, $indent = '') |
||
| 10 | { |
||
| 11 | switch (gettype($var)) { |
||
| 12 | case 'string': |
||
| 13 | return '"'.addcslashes($var, "\\\$\"\r\n\t\v\f").'"'; |
||
| 14 | case 'array': |
||
| 15 | $indexed = array_keys($var) === range(0, count($var) - 1); |
||
| 16 | $r = []; |
||
| 17 | foreach ($var as $key => $value) { |
||
| 18 | $r[] = "$indent " |
||
| 19 | .($indexed ? '' : self::varExport($key).' => ') |
||
| 20 | .self::varExport($value, "$indent "); |
||
| 21 | } |
||
| 22 | |||
| 23 | return "[\n".implode(",\n", $r)."\n".$indent.']'; |
||
| 24 | case 'boolean': |
||
| 25 | return $var ? 'true' : 'false'; |
||
| 26 | default: |
||
| 27 | return var_export($var, true); |
||
| 28 | } |
||
| 29 | } |
||
| 30 | |||
| 31 | 1 | public static function keyValues($values, $keys) |
|
| 39 | |||
| 40 | 1 | public static function asArray($value) |
|
| 50 | } |
||
| 51 |