| Conditions | 7 |
| Paths | 13 |
| Total Lines | 22 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 7 |
| Changes | 0 | ||
| 1 | <?php |
||
| 48 | 2 | private function cleanRawData(array $rawData, int $numericPrefixLength): array |
|
| 49 | { |
||
| 50 | 2 | $data = []; |
|
| 51 | 2 | foreach ($rawData as $rawKey => $value) { |
|
| 52 | 2 | if (0 !== $numericPrefixLength && 0 === strpos($rawKey, $this->numericPrefix)) { |
|
| 53 | 1 | $rawSubKey = substr($rawKey, $numericPrefixLength); |
|
| 54 | 1 | if (is_numeric($rawSubKey)) { |
|
| 55 | 1 | $rawKey = $rawSubKey; |
|
| 56 | } |
||
| 57 | } |
||
| 58 | |||
| 59 | 2 | $key = is_numeric($rawKey) ? (int) $rawKey : $rawKey; |
|
| 60 | |||
| 61 | 2 | if (is_array($value)) { |
|
| 62 | 2 | $data[$key] = $this->cleanRawData($value, $numericPrefixLength); |
|
| 63 | } else { |
||
| 64 | 2 | $data[$key] = $value; |
|
| 65 | } |
||
| 66 | } |
||
| 67 | |||
| 68 | 2 | return $data; |
|
| 69 | } |
||
| 70 | } |
||
| 71 |
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.