1 | <?php |
||
9 | class Arr |
||
10 | { |
||
11 | /** |
||
12 | * Determine whether the given value is array accessible. |
||
13 | * |
||
14 | * @param mixed $value |
||
15 | * |
||
16 | * @return bool |
||
17 | */ |
||
18 | 8 | public static function accessible($value): bool |
|
22 | |||
23 | /** |
||
24 | * Determine if the given key exists in the provided array. |
||
25 | * |
||
26 | * @param \ArrayAccess|array $array |
||
27 | * @param string|int $key |
||
28 | * |
||
29 | * @return bool |
||
30 | */ |
||
31 | 15 | public static function exists($array, $key): bool |
|
39 | |||
40 | /** |
||
41 | * Check if an item or items exist in an array using "dot" notation. |
||
42 | * |
||
43 | * @param \ArrayAccess|array $array |
||
44 | * @param array $keys |
||
45 | * |
||
46 | * @return bool |
||
47 | */ |
||
48 | 3 | public static function has($array, array $keys): bool |
|
70 | |||
71 | /** |
||
72 | * Get an item from an array using "dot" notation. |
||
73 | * |
||
74 | * @param \ArrayAccess|array $array |
||
75 | * @param string|null $key |
||
76 | * @param mixed $default |
||
77 | * |
||
78 | * @return mixed |
||
79 | */ |
||
80 | 12 | public static function get($array, ?string $key, $default = null) |
|
99 | |||
100 | /** |
||
101 | * Set an array item to a given value using "dot" notation. |
||
102 | * |
||
103 | * If no key is given to the method, the entire array will be replaced. |
||
104 | * |
||
105 | * @param array $array |
||
106 | * @param string $key |
||
107 | * @param mixed $value |
||
108 | * |
||
109 | * @return array |
||
110 | */ |
||
111 | 2 | public static function set(array &$array, string $key, $value): array |
|
128 | |||
129 | /** |
||
130 | * Remove one or many array items from a given array using "dot" notation. |
||
131 | * |
||
132 | * @param array $array |
||
133 | * @param array|string $keys |
||
134 | * |
||
135 | * @return void |
||
136 | */ |
||
137 | 1 | public static function forget(&$array, $keys): void |
|
165 | } |
||
166 |