| Conditions | 7 |
| Paths | 11 |
| Total Lines | 25 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 7 |
| Changes | 0 | ||
| 1 | <?php |
||
| 41 | 1 | private function fixValues(array $rawData): array |
|
| 42 | { |
||
| 43 | 1 | $data = []; |
|
| 44 | 1 | foreach ($rawData as $rawKey => $value) { |
|
| 45 | 1 | $key = (string) (int) $rawKey === $rawData ? (int) $rawKey : $rawKey; |
|
| 46 | |||
| 47 | 1 | if (is_array($value)) { |
|
| 48 | 1 | $data[$key] = $this->fixValues($value); |
|
| 49 | } else { |
||
| 50 | 1 | $data[$key] = $this->fixValue($value); |
|
| 51 | } |
||
| 52 | } |
||
| 53 | |||
| 54 | 1 | return $data; |
|
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @param $value |
||
| 59 | * |
||
| 60 | * @return float|int|null|string |
||
| 61 | */ |
||
| 62 | 1 | private function fixValue($value) |
|
| 63 | { |
||
| 64 | 1 | if (is_numeric($value)) { |
|
| 65 | 1 | if ((string) (int) $value === $value) { |
|
| 66 | 1 | return (int) $value; |
|
| 79 |
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.