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