1 | <?php |
||
8 | class Arr |
||
9 | { |
||
10 | |||
11 | /** |
||
12 | * @param array $storage |
||
13 | * @param callable $callback |
||
14 | * |
||
15 | * @return bool |
||
16 | */ |
||
17 | 1 | public static function walkRecursive(array &$storage, callable $callback) |
|
21 | |||
22 | /** |
||
23 | * @param array $storage |
||
24 | * @param callable $callback |
||
25 | * |
||
26 | * @return array |
||
27 | */ |
||
28 | 1 | public static function map(array $storage, $callback) |
|
32 | |||
33 | /** |
||
34 | * @param array $storage |
||
35 | * @param int $offset |
||
36 | * @param int $length |
||
37 | * |
||
38 | * @return array |
||
39 | */ |
||
40 | 1 | public static function slice(array $storage, $offset, $length = null) |
|
44 | |||
45 | /** |
||
46 | * @param array $first |
||
47 | * @param array[] ...$second |
||
48 | * |
||
49 | * @return array |
||
50 | */ |
||
51 | 1 | public static function merge(array $first, array ...$second) |
|
55 | |||
56 | /** |
||
57 | * @param array $storage |
||
58 | * @param callable $callback |
||
59 | * |
||
60 | * @return array |
||
61 | */ |
||
62 | 1 | public static function filter(array $storage, $callback) |
|
66 | |||
67 | /** |
||
68 | * @param $string |
||
69 | * @param $length |
||
70 | * @param int $start |
||
71 | * |
||
72 | * @return array |
||
73 | */ |
||
74 | 1 | public static function fill($string, $length, $start = 0) |
|
78 | |||
79 | /** |
||
80 | * @param mixed $begin |
||
81 | * @param mixed $end |
||
82 | * @param int $step |
||
83 | * |
||
84 | * @return array |
||
85 | */ |
||
86 | 1 | public static function range($begin, $end, $step = 1) |
|
90 | |||
91 | /** |
||
92 | * @param array $storage |
||
93 | * @param mixed $needle |
||
94 | * @param bool $strict |
||
95 | * |
||
96 | * @return bool |
||
97 | */ |
||
98 | 1 | public static function in(array $storage, $needle, $strict = true) |
|
102 | |||
103 | /** |
||
104 | * @param array $storage |
||
105 | * |
||
106 | * @return bool |
||
107 | */ |
||
108 | 1 | public static function shuffle(array &$storage) |
|
112 | |||
113 | /** |
||
114 | * @param array $storage |
||
115 | * @param string $path |
||
116 | * @param mixed $value |
||
117 | */ |
||
118 | 1 | public static function set(array &$storage, $path, $value) |
|
123 | |||
124 | /** |
||
125 | * @param array $storage |
||
126 | * @param string $path |
||
127 | */ |
||
128 | 1 | public static function remove(array &$storage, $path) |
|
133 | |||
134 | /** |
||
135 | * @param array $storage |
||
136 | * @param string $key |
||
137 | * |
||
138 | * @return array|mixed |
||
139 | * |
||
140 | * @throws NotFound\Path |
||
141 | * @throws Exceptions\Blank |
||
142 | */ |
||
143 | 3 | public static function getRequired(array $storage, $key) |
|
147 | |||
148 | /** |
||
149 | * @param array $storage |
||
150 | * @param array $keys |
||
151 | * |
||
152 | * @return array|mixed |
||
153 | * |
||
154 | * @throws NotFound\Path |
||
155 | * @throws Exceptions\Blank |
||
156 | */ |
||
157 | 6 | protected static function findPath(array $storage, array $keys) |
|
178 | |||
179 | /** |
||
180 | * @param array $storage |
||
181 | * @param $mixed |
||
182 | * |
||
183 | * @return int |
||
184 | */ |
||
185 | 1 | public static function push(array &$storage, $mixed) |
|
189 | |||
190 | /** |
||
191 | * @param array $storage |
||
192 | * |
||
193 | * @return mixed |
||
194 | */ |
||
195 | 1 | public static function pop(array &$storage) |
|
199 | |||
200 | /** |
||
201 | * @param array $storage |
||
202 | * |
||
203 | * @return mixed |
||
204 | */ |
||
205 | 1 | public static function shift(array &$storage) |
|
209 | |||
210 | /** |
||
211 | * @param array $storage |
||
212 | * @param $mixed |
||
213 | * |
||
214 | * @return int |
||
215 | */ |
||
216 | 1 | public static function unShift(array &$storage, $mixed) |
|
220 | |||
221 | /** |
||
222 | * @param array $storage |
||
223 | * @param string $key |
||
224 | * @param mixed $default |
||
225 | * |
||
226 | * @return mixed |
||
227 | */ |
||
228 | 3 | public static function get(array $storage, $key, $default = null) |
|
239 | |||
240 | /** |
||
241 | * @param array|\Traversable $iterator |
||
242 | * |
||
243 | * @return array |
||
244 | */ |
||
245 | 1 | public static function iterator($iterator) |
|
254 | |||
255 | /** |
||
256 | * @param array $storage |
||
257 | * |
||
258 | * @return array |
||
259 | */ |
||
260 | 2 | public static function getValues(array $storage) |
|
264 | |||
265 | /** |
||
266 | * @param array $storage |
||
267 | * |
||
268 | * @return array |
||
269 | */ |
||
270 | 2 | public static function getKeys(array $storage) |
|
274 | |||
275 | /** |
||
276 | * @param string $offset |
||
277 | * |
||
278 | * @return array |
||
279 | */ |
||
280 | 7 | public static function keys($offset) |
|
287 | |||
288 | /** |
||
289 | * @param array $storage |
||
290 | * @param string $key |
||
291 | * |
||
292 | * @return bool |
||
293 | */ |
||
294 | 7 | public static function keyExists(array $storage, $key) |
|
298 | |||
299 | /** |
||
300 | * @param array $storage |
||
301 | * @param string $key |
||
302 | * |
||
303 | * @return mixed |
||
304 | */ |
||
305 | 1 | public static function at(array $storage, $key) |
|
309 | |||
310 | /** |
||
311 | * @param array $storage |
||
312 | * @param string $key |
||
313 | * @param mixed $value |
||
314 | */ |
||
315 | 1 | public static function initOrPush(array &$storage, $key, $value) |
|
324 | |||
325 | /** |
||
326 | * @param array $storage |
||
327 | * @param string $path |
||
328 | * @param string $lastKey |
||
329 | * |
||
330 | * @return array |
||
331 | */ |
||
332 | 2 | protected static function &link(array &$storage, $path, &$lastKey) |
|
349 | |||
350 | } |
||
351 |