| Total Complexity | 9 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | class Util |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * Normalize a given index within the range of the container length. |
||
| 18 | * |
||
| 19 | * @param int $index The index to normalize. |
||
| 20 | * @param int $containerLength The length of the container. |
||
| 21 | * @param bool $throwError Flag to indicate if an IndexError should be thrown for out-of-range index. |
||
| 22 | * |
||
| 23 | * @return int The normalized index within the valid range of the container. |
||
| 24 | * |
||
| 25 | * @throws IndexError if the index is out of range and $throwError is true. |
||
| 26 | */ |
||
| 27 | public static function normalizeIndex(int $index, int $containerLength, bool $throwError = true): int |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Check if an array is sequential (indexed from 0 to n-1). |
||
| 38 | * |
||
| 39 | * @param array<mixed> $source The array to check for sequential indexing. |
||
| 40 | * @param bool $forceCustomImplementation Flag only for tests (to test custom implementation of array_is_list). |
||
| 41 | * |
||
| 42 | * @return bool Returns true if the array has sequential indexing, false otherwise. |
||
| 43 | */ |
||
| 44 | public static function isArraySequential(array $source, bool $forceCustomImplementation = false): bool |
||
| 52 |