1 | <?php |
||
13 | class Arr |
||
14 | { |
||
15 | /** |
||
16 | * Determine whether the given value is array accessible. |
||
17 | * |
||
18 | * @param mixed $value |
||
19 | * @return bool |
||
20 | */ |
||
21 | public static function accessible($value) |
||
25 | |||
26 | /** |
||
27 | * Determine if the given key exists in the provided array. |
||
28 | * |
||
29 | * @param \ArrayAccess|array $array |
||
30 | * @param string|int $key |
||
31 | * @return bool |
||
32 | */ |
||
33 | public static function exists($array, $key) |
||
41 | |||
42 | /** |
||
43 | * Get a subset of the items from the given array. |
||
44 | * |
||
45 | * @param array $array |
||
46 | * @param array|string $keys |
||
47 | * @return array |
||
48 | */ |
||
49 | public static function only($array, $keys) |
||
57 | |||
58 | /** |
||
59 | * Set an array item to a given value using "dot" notation. |
||
60 | * |
||
61 | * If no key is given to the method, the entire array will be replaced. |
||
62 | * |
||
63 | * @param array $array |
||
64 | * @param string $key |
||
65 | * @param mixed $value |
||
66 | * |
||
67 | * @return array |
||
68 | */ |
||
69 | public static function set(&$array, $key, $value) |
||
90 | |||
91 | /** |
||
92 | * Get an item from an array using "dot" notation. |
||
93 | * |
||
94 | * @param array $array |
||
95 | * @param string $key |
||
96 | * @param mixed $default |
||
97 | * |
||
98 | * @return mixed |
||
99 | */ |
||
100 | public static function get($array, $key, $default = null) |
||
119 | |||
120 | /** |
||
121 | * To determine Whether an array item exists |
||
122 | * |
||
123 | * @static |
||
124 | * @param array $array |
||
125 | * @param array|string $keys |
||
126 | * @return bool |
||
127 | */ |
||
128 | public static function has($array, $keys) |
||
162 | |||
163 | /** |
||
164 | * Remove one or many array items from a given array using "dot" notation. |
||
165 | * |
||
166 | * @param array $array |
||
167 | * @param array|string $keys |
||
168 | */ |
||
169 | public static function forget(&$array, $keys) |
||
190 | } |
||
191 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.