| Conditions | 7 |
| Paths | 7 |
| Total Lines | 21 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 8.0504 |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | 1 | public static function varExport($var, $indent = '') |
|
| 10 | { |
||
| 11 | 1 | switch (gettype($var)) { |
|
| 12 | 1 | case 'string': |
|
| 13 | 1 | return '"'.addcslashes($var, "\\\$\"\r\n\t\v\f").'"'; |
|
| 14 | 1 | case 'array': |
|
| 15 | 1 | $indexed = array_keys($var) === range(0, count($var) - 1); |
|
| 16 | 1 | $r = []; |
|
| 17 | 1 | foreach ($var as $key => $value) { |
|
| 18 | 1 | $r[] = "$indent " |
|
| 19 | 1 | .($indexed ? '' : self::varExport($key).' => ') |
|
| 20 | 1 | .self::varExport($value, "$indent "); |
|
| 21 | 1 | } |
|
| 22 | |||
| 23 | 1 | 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 | |||
| 51 |