| Conditions | 5 |
| Paths | 2 |
| Total Lines | 23 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 21 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | 1 | public static function toPhp($var) |
|
| 25 | { |
||
| 26 | 1 | switch (gettype($var)) { |
|
| 27 | 1 | case 'array': |
|
| 28 | 1 | $skipKeys = (range(0, count($var) - 1) === array_keys($var)); |
|
| 29 | 1 | $ret = 'array('; |
|
| 30 | 1 | $i = 0; |
|
| 31 | 1 | foreach ($var as $key => $value) { |
|
| 32 | 1 | if ($i++ > 0) { |
|
| 33 | 1 | $ret .= ', '; |
|
| 34 | 1 | } |
|
| 35 | 1 | if (!$skipKeys) { |
|
| 36 | 1 | $ret .= self::toPhp($key) . ' => '; |
|
| 37 | 1 | } |
|
| 38 | 1 | $ret .= self::toPhp($value); |
|
| 39 | 1 | } |
|
| 40 | 1 | $ret .= ')'; |
|
| 41 | 1 | break; |
|
| 42 | 1 | default: |
|
| 43 | 1 | $ret = var_export($var, true); |
|
| 44 | 1 | } |
|
| 45 | 1 | return $ret; |
|
| 46 | } |
||
| 47 | |||
| 59 | } |