| Conditions | 5 |
| Paths | 6 |
| Total Lines | 7 |
| Code Lines | 4 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | public static function normalizeIndex(int $index, int $containerLength, bool $throwError = true): int |
||
| 10 | { |
||
| 11 | $dist = $index >= 0 ? $index : abs($index) - 1; |
||
| 12 | if ($throwError && $dist >= $containerLength) { |
||
| 13 | throw new IndexError("Index {$index} is out of range."); |
||
| 14 | } |
||
| 15 | return $index < 0 ? $containerLength + $index : $index; |
||
| 16 | } |
||
| 26 |