| 1 | <?php |
||
| 5 | class ArrayHelper |
||
| 6 | { |
||
| 7 | /** @var array */ |
||
| 8 | protected $array; |
||
| 9 | |||
| 10 | /** |
||
| 11 | * ArrayHelper constructor. Accepts and stores an array. |
||
| 12 | * |
||
| 13 | * @throws \InvalidArgumentException if not initialized with an array |
||
| 14 | * @param mixed[] $array The array needing help |
||
| 15 | */ |
||
| 16 | 29 | public function __construct($array) |
|
| 24 | |||
| 25 | /** |
||
| 26 | * Returns the value corresponding with a supplied key; returns FALSE if the supplied key does not exist within |
||
| 27 | * the array. |
||
| 28 | * |
||
| 29 | * **WARNING** This function may return FALSE or a non-Boolean value that evaluates to FALSE even if a supplied |
||
| 30 | * key exists |
||
| 31 | * |
||
| 32 | * @param int|string $key The key to look up |
||
| 33 | * @return bool|mixed Returns FALSE if the supplied key does not exist within the array |
||
| 34 | * Returns the value corresponding with the key otherwise |
||
| 35 | */ |
||
| 36 | 10 | public function valueLookup($key) |
|
| 46 | |||
| 47 | /** |
||
| 48 | * Returns a copy of the array with numeric key/value pairs stripped. |
||
| 49 | * |
||
| 50 | * Preserves the original array. |
||
| 51 | * |
||
| 52 | * @return mixed[] A copy of the array with numeric key/value pairs stripped |
||
| 53 | */ |
||
| 54 | 20 | public function removeNumericKeys() |
|
| 66 | } |
||
| 67 |