| Total Complexity | 4 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 5 | class ArrayHelpers |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * Checks if an array is associative. |
||
| 9 | * |
||
| 10 | * @since 0.1.0 |
||
| 11 | * |
||
| 12 | * @param array $array The array to check. |
||
| 13 | * |
||
| 14 | * @return boolean |
||
| 15 | */ |
||
| 16 | public static function isAssoc(array $array) |
||
| 17 | { |
||
| 18 | _deprecated_function(__METHOD__, '1.4.0'); |
||
| 19 | // Keys of the array |
||
| 20 | $keys = array_keys($array); |
||
| 21 | |||
| 22 | // If the array keys of the keys match the keys, then the array must |
||
| 23 | // not be associative (e.g. the keys array looked like {0:0, 1:1...}). |
||
| 24 | return array_keys($keys) !== $keys; |
||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Converts indexed values to associative keys. |
||
| 29 | * |
||
| 30 | * @since 0.1.0 |
||
| 31 | * |
||
| 32 | * @param array $array The array to convert. |
||
| 33 | * |
||
| 34 | * @return array |
||
| 35 | */ |
||
| 36 | public static function indexedValuesToAssocKeys(array $array) |
||
| 48 | } |
||
| 49 | } |
||
| 50 |