| Conditions | 6 |
| Paths | 7 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 5 |
| Ratio | 27.78 % |
| Tests | 8 |
| CRAP Score | 6.0493 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 29 | 2 | function toArray($data) |
|
| 30 | {
|
||
| 31 | 2 | if (!$data) {
|
|
| 32 | return []; |
||
| 33 | } |
||
| 34 | |||
| 35 | 2 | if (is_object($data)) {
|
|
| 36 | 2 | $data = get_object_vars($data); |
|
| 37 | } |
||
| 38 | |||
| 39 | 2 | View Code Duplication | foreach ($data as $k => $v) {
|
| 40 | 2 | if (is_array($v) || is_object($v)) {
|
|
| 41 | 2 | $data[$k] = $this->toArray($v); |
|
| 42 | } |
||
| 43 | } |
||
| 44 | |||
| 45 | 2 | return $data; |
|
| 46 | } |
||
| 47 | } |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.