| Conditions | 7 |
| Paths | 11 |
| Total Lines | 25 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 56 |
| Changes | 0 | ||
| 1 | <?php |
||
| 41 | private function cleanRawData(array $rawData): array |
||
| 42 | { |
||
| 43 | $data = []; |
||
| 44 | foreach ($rawData as $rawKey => $value) { |
||
| 45 | $key = (string) (int) $rawKey === $rawData ? (int) $rawKey : $rawKey; |
||
| 46 | |||
| 47 | if (is_array($value)) { |
||
| 48 | $data[$key] = $this->cleanRawData($value); |
||
| 49 | } else { |
||
| 50 | if (is_numeric($value)) { |
||
| 51 | if ((string) (int) $value === $value) { |
||
| 52 | $value = (int) $value; |
||
| 53 | } else { |
||
| 54 | $value = (float) $value; |
||
| 55 | } |
||
| 56 | } elseif ('' === $value) { |
||
| 57 | $value = null; |
||
| 58 | } |
||
| 59 | |||
| 60 | $data[$key] = $value; |
||
| 61 | } |
||
| 62 | } |
||
| 63 | |||
| 64 | return $data; |
||
| 65 | } |
||
| 66 | } |
||
| 67 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.