| 148 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
namespace Illuminate\Support;
|
|
|
4 |
|
|
|
5 |
use CachingIterator;
|
|
|
6 |
use Countable;
|
|
|
7 |
use Illuminate\Contracts\Support\Arrayable;
|
|
|
8 |
use Illuminate\Contracts\Support\Jsonable;
|
|
|
9 |
use IteratorAggregate;
|
|
|
10 |
use JsonSerializable;
|
|
|
11 |
use Traversable;
|
|
|
12 |
|
|
|
13 |
/**
|
|
|
14 |
* @template TKey of array-key
|
|
|
15 |
* @template TValue
|
|
|
16 |
*
|
|
|
17 |
* @extends \Illuminate\Contracts\Support\Arrayable<TKey, TValue>
|
|
|
18 |
* @extends \IteratorAggregate<TKey, TValue>
|
|
|
19 |
*/
|
|
|
20 |
interface Enumerable extends Arrayable, Countable, IteratorAggregate, Jsonable, JsonSerializable
|
|
|
21 |
{
|
|
|
22 |
/**
|
|
|
23 |
* Create a new collection instance if the value isn't one already.
|
|
|
24 |
*
|
|
|
25 |
* @template TMakeKey of array-key
|
|
|
26 |
* @template TMakeValue
|
|
|
27 |
*
|
|
|
28 |
* @param \Illuminate\Contracts\Support\Arrayable<TMakeKey, TMakeValue>|iterable<TMakeKey, TMakeValue>|null $items
|
|
|
29 |
* @return static<TMakeKey, TMakeValue>
|
|
|
30 |
*/
|
|
|
31 |
public static function make($items = []);
|
|
|
32 |
|
|
|
33 |
/**
|
|
|
34 |
* Create a new instance by invoking the callback a given amount of times.
|
|
|
35 |
*
|
|
|
36 |
* @param int $number
|
|
|
37 |
* @param callable|null $callback
|
|
|
38 |
* @return static
|
|
|
39 |
*/
|
|
|
40 |
public static function times($number, callable $callback = null);
|
|
|
41 |
|
|
|
42 |
/**
|
|
|
43 |
* Create a collection with the given range.
|
|
|
44 |
*
|
|
|
45 |
* @param int $from
|
|
|
46 |
* @param int $to
|
|
|
47 |
* @return static
|
|
|
48 |
*/
|
|
|
49 |
public static function range($from, $to);
|
|
|
50 |
|
|
|
51 |
/**
|
|
|
52 |
* Wrap the given value in a collection if applicable.
|
|
|
53 |
*
|
|
|
54 |
* @template TWrapValue
|
|
|
55 |
*
|
| 621 |
lars |
56 |
* @param iterable<array-key, TWrapValue>|TWrapValue $value
|
|
|
57 |
* @return static<array-key, TWrapValue>
|
| 148 |
lars |
58 |
*/
|
|
|
59 |
public static function wrap($value);
|
|
|
60 |
|
|
|
61 |
/**
|
|
|
62 |
* Get the underlying items from the given collection if applicable.
|
|
|
63 |
*
|
|
|
64 |
* @template TUnwrapKey of array-key
|
|
|
65 |
* @template TUnwrapValue
|
|
|
66 |
*
|
|
|
67 |
* @param array<TUnwrapKey, TUnwrapValue>|static<TUnwrapKey, TUnwrapValue> $value
|
|
|
68 |
* @return array<TUnwrapKey, TUnwrapValue>
|
|
|
69 |
*/
|
|
|
70 |
public static function unwrap($value);
|
|
|
71 |
|
|
|
72 |
/**
|
|
|
73 |
* Create a new instance with no items.
|
|
|
74 |
*
|
|
|
75 |
* @return static
|
|
|
76 |
*/
|
|
|
77 |
public static function empty();
|
|
|
78 |
|
|
|
79 |
/**
|
|
|
80 |
* Get all items in the enumerable.
|
|
|
81 |
*
|
|
|
82 |
* @return array
|
|
|
83 |
*/
|
|
|
84 |
public function all();
|
|
|
85 |
|
|
|
86 |
/**
|
|
|
87 |
* Alias for the "avg" method.
|
|
|
88 |
*
|
|
|
89 |
* @param (callable(TValue): float|int)|string|null $callback
|
|
|
90 |
* @return float|int|null
|
|
|
91 |
*/
|
|
|
92 |
public function average($callback = null);
|
|
|
93 |
|
|
|
94 |
/**
|
|
|
95 |
* Get the median of a given key.
|
|
|
96 |
*
|
|
|
97 |
* @param string|array<array-key, string>|null $key
|
|
|
98 |
* @return float|int|null
|
|
|
99 |
*/
|
|
|
100 |
public function median($key = null);
|
|
|
101 |
|
|
|
102 |
/**
|
|
|
103 |
* Get the mode of a given key.
|
|
|
104 |
*
|
|
|
105 |
* @param string|array<array-key, string>|null $key
|
|
|
106 |
* @return array<int, float|int>|null
|
|
|
107 |
*/
|
|
|
108 |
public function mode($key = null);
|
|
|
109 |
|
|
|
110 |
/**
|
|
|
111 |
* Collapse the items into a single enumerable.
|
|
|
112 |
*
|
|
|
113 |
* @return static<int, mixed>
|
|
|
114 |
*/
|
|
|
115 |
public function collapse();
|
|
|
116 |
|
|
|
117 |
/**
|
|
|
118 |
* Alias for the "contains" method.
|
|
|
119 |
*
|
|
|
120 |
* @param (callable(TValue, TKey): bool)|TValue|string $key
|
|
|
121 |
* @param mixed $operator
|
|
|
122 |
* @param mixed $value
|
|
|
123 |
* @return bool
|
|
|
124 |
*/
|
|
|
125 |
public function some($key, $operator = null, $value = null);
|
|
|
126 |
|
|
|
127 |
/**
|
|
|
128 |
* Determine if an item exists, using strict comparison.
|
|
|
129 |
*
|
|
|
130 |
* @param (callable(TValue): bool)|TValue|array-key $key
|
|
|
131 |
* @param TValue|null $value
|
|
|
132 |
* @return bool
|
|
|
133 |
*/
|
|
|
134 |
public function containsStrict($key, $value = null);
|
|
|
135 |
|
|
|
136 |
/**
|
|
|
137 |
* Get the average value of a given key.
|
|
|
138 |
*
|
|
|
139 |
* @param (callable(TValue): float|int)|string|null $callback
|
|
|
140 |
* @return float|int|null
|
|
|
141 |
*/
|
|
|
142 |
public function avg($callback = null);
|
|
|
143 |
|
|
|
144 |
/**
|
|
|
145 |
* Determine if an item exists in the enumerable.
|
|
|
146 |
*
|
|
|
147 |
* @param (callable(TValue, TKey): bool)|TValue|string $key
|
|
|
148 |
* @param mixed $operator
|
|
|
149 |
* @param mixed $value
|
|
|
150 |
* @return bool
|
|
|
151 |
*/
|
|
|
152 |
public function contains($key, $operator = null, $value = null);
|
|
|
153 |
|
|
|
154 |
/**
|
|
|
155 |
* Determine if an item is not contained in the collection.
|
|
|
156 |
*
|
|
|
157 |
* @param mixed $key
|
|
|
158 |
* @param mixed $operator
|
|
|
159 |
* @param mixed $value
|
|
|
160 |
* @return bool
|
|
|
161 |
*/
|
|
|
162 |
public function doesntContain($key, $operator = null, $value = null);
|
|
|
163 |
|
|
|
164 |
/**
|
|
|
165 |
* Cross join with the given lists, returning all possible permutations.
|
|
|
166 |
*
|
|
|
167 |
* @template TCrossJoinKey
|
|
|
168 |
* @template TCrossJoinValue
|
|
|
169 |
*
|
|
|
170 |
* @param \Illuminate\Contracts\Support\Arrayable<TCrossJoinKey, TCrossJoinValue>|iterable<TCrossJoinKey, TCrossJoinValue> ...$lists
|
|
|
171 |
* @return static<int, array<int, TValue|TCrossJoinValue>>
|
|
|
172 |
*/
|
|
|
173 |
public function crossJoin(...$lists);
|
|
|
174 |
|
|
|
175 |
/**
|
|
|
176 |
* Dump the collection and end the script.
|
|
|
177 |
*
|
|
|
178 |
* @param mixed ...$args
|
|
|
179 |
* @return never
|
|
|
180 |
*/
|
|
|
181 |
public function dd(...$args);
|
|
|
182 |
|
|
|
183 |
/**
|
|
|
184 |
* Dump the collection.
|
|
|
185 |
*
|
|
|
186 |
* @return $this
|
|
|
187 |
*/
|
|
|
188 |
public function dump();
|
|
|
189 |
|
|
|
190 |
/**
|
|
|
191 |
* Get the items that are not present in the given items.
|
|
|
192 |
*
|
|
|
193 |
* @param \Illuminate\Contracts\Support\Arrayable<array-key, TValue>|iterable<array-key, TValue> $items
|
|
|
194 |
* @return static
|
|
|
195 |
*/
|
|
|
196 |
public function diff($items);
|
|
|
197 |
|
|
|
198 |
/**
|
|
|
199 |
* Get the items that are not present in the given items, using the callback.
|
|
|
200 |
*
|
|
|
201 |
* @param \Illuminate\Contracts\Support\Arrayable<array-key, TValue>|iterable<array-key, TValue> $items
|
|
|
202 |
* @param callable(TValue, TValue): int $callback
|
|
|
203 |
* @return static
|
|
|
204 |
*/
|
|
|
205 |
public function diffUsing($items, callable $callback);
|
|
|
206 |
|
|
|
207 |
/**
|
|
|
208 |
* Get the items whose keys and values are not present in the given items.
|
|
|
209 |
*
|
|
|
210 |
* @param \Illuminate\Contracts\Support\Arrayable<TKey, TValue>|iterable<TKey, TValue> $items
|
|
|
211 |
* @return static
|
|
|
212 |
*/
|
|
|
213 |
public function diffAssoc($items);
|
|
|
214 |
|
|
|
215 |
/**
|
|
|
216 |
* Get the items whose keys and values are not present in the given items, using the callback.
|
|
|
217 |
*
|
|
|
218 |
* @param \Illuminate\Contracts\Support\Arrayable<TKey, TValue>|iterable<TKey, TValue> $items
|
|
|
219 |
* @param callable(TKey, TKey): int $callback
|
|
|
220 |
* @return static
|
|
|
221 |
*/
|
|
|
222 |
public function diffAssocUsing($items, callable $callback);
|
|
|
223 |
|
|
|
224 |
/**
|
|
|
225 |
* Get the items whose keys are not present in the given items.
|
|
|
226 |
*
|
|
|
227 |
* @param \Illuminate\Contracts\Support\Arrayable<TKey, TValue>|iterable<TKey, TValue> $items
|
|
|
228 |
* @return static
|
|
|
229 |
*/
|
|
|
230 |
public function diffKeys($items);
|
|
|
231 |
|
|
|
232 |
/**
|
|
|
233 |
* Get the items whose keys are not present in the given items, using the callback.
|
|
|
234 |
*
|
|
|
235 |
* @param \Illuminate\Contracts\Support\Arrayable<TKey, TValue>|iterable<TKey, TValue> $items
|
|
|
236 |
* @param callable(TKey, TKey): int $callback
|
|
|
237 |
* @return static
|
|
|
238 |
*/
|
|
|
239 |
public function diffKeysUsing($items, callable $callback);
|
|
|
240 |
|
|
|
241 |
/**
|
|
|
242 |
* Retrieve duplicate items.
|
|
|
243 |
*
|
|
|
244 |
* @param (callable(TValue): bool)|string|null $callback
|
|
|
245 |
* @param bool $strict
|
|
|
246 |
* @return static
|
|
|
247 |
*/
|
|
|
248 |
public function duplicates($callback = null, $strict = false);
|
|
|
249 |
|
|
|
250 |
/**
|
|
|
251 |
* Retrieve duplicate items using strict comparison.
|
|
|
252 |
*
|
|
|
253 |
* @param (callable(TValue): bool)|string|null $callback
|
|
|
254 |
* @return static
|
|
|
255 |
*/
|
|
|
256 |
public function duplicatesStrict($callback = null);
|
|
|
257 |
|
|
|
258 |
/**
|
|
|
259 |
* Execute a callback over each item.
|
|
|
260 |
*
|
|
|
261 |
* @param callable(TValue, TKey): mixed $callback
|
|
|
262 |
* @return $this
|
|
|
263 |
*/
|
|
|
264 |
public function each(callable $callback);
|
|
|
265 |
|
|
|
266 |
/**
|
|
|
267 |
* Execute a callback over each nested chunk of items.
|
|
|
268 |
*
|
|
|
269 |
* @param callable $callback
|
|
|
270 |
* @return static
|
|
|
271 |
*/
|
|
|
272 |
public function eachSpread(callable $callback);
|
|
|
273 |
|
|
|
274 |
/**
|
|
|
275 |
* Determine if all items pass the given truth test.
|
|
|
276 |
*
|
|
|
277 |
* @param (callable(TValue, TKey): bool)|TValue|string $key
|
|
|
278 |
* @param mixed $operator
|
|
|
279 |
* @param mixed $value
|
|
|
280 |
* @return bool
|
|
|
281 |
*/
|
|
|
282 |
public function every($key, $operator = null, $value = null);
|
|
|
283 |
|
|
|
284 |
/**
|
|
|
285 |
* Get all items except for those with the specified keys.
|
|
|
286 |
*
|
|
|
287 |
* @param \Illuminate\Support\Enumerable<array-key, TKey>|array<array-key, TKey> $keys
|
|
|
288 |
* @return static
|
|
|
289 |
*/
|
|
|
290 |
public function except($keys);
|
|
|
291 |
|
|
|
292 |
/**
|
|
|
293 |
* Run a filter over each of the items.
|
|
|
294 |
*
|
|
|
295 |
* @param (callable(TValue): bool)|null $callback
|
|
|
296 |
* @return static
|
|
|
297 |
*/
|
|
|
298 |
public function filter(callable $callback = null);
|
|
|
299 |
|
|
|
300 |
/**
|
|
|
301 |
* Apply the callback if the given "value" is (or resolves to) truthy.
|
|
|
302 |
*
|
|
|
303 |
* @template TWhenReturnType as null
|
|
|
304 |
*
|
|
|
305 |
* @param bool $value
|
|
|
306 |
* @param (callable($this): TWhenReturnType)|null $callback
|
|
|
307 |
* @param (callable($this): TWhenReturnType)|null $default
|
|
|
308 |
* @return $this|TWhenReturnType
|
|
|
309 |
*/
|
|
|
310 |
public function when($value, callable $callback = null, callable $default = null);
|
|
|
311 |
|
|
|
312 |
/**
|
|
|
313 |
* Apply the callback if the collection is empty.
|
|
|
314 |
*
|
|
|
315 |
* @template TWhenEmptyReturnType
|
|
|
316 |
*
|
|
|
317 |
* @param (callable($this): TWhenEmptyReturnType) $callback
|
|
|
318 |
* @param (callable($this): TWhenEmptyReturnType)|null $default
|
|
|
319 |
* @return $this|TWhenEmptyReturnType
|
|
|
320 |
*/
|
|
|
321 |
public function whenEmpty(callable $callback, callable $default = null);
|
|
|
322 |
|
|
|
323 |
/**
|
|
|
324 |
* Apply the callback if the collection is not empty.
|
|
|
325 |
*
|
|
|
326 |
* @template TWhenNotEmptyReturnType
|
|
|
327 |
*
|
|
|
328 |
* @param callable($this): TWhenNotEmptyReturnType $callback
|
|
|
329 |
* @param (callable($this): TWhenNotEmptyReturnType)|null $default
|
|
|
330 |
* @return $this|TWhenNotEmptyReturnType
|
|
|
331 |
*/
|
|
|
332 |
public function whenNotEmpty(callable $callback, callable $default = null);
|
|
|
333 |
|
|
|
334 |
/**
|
|
|
335 |
* Apply the callback if the given "value" is (or resolves to) truthy.
|
|
|
336 |
*
|
|
|
337 |
* @template TUnlessReturnType
|
|
|
338 |
*
|
|
|
339 |
* @param bool $value
|
|
|
340 |
* @param (callable($this): TUnlessReturnType) $callback
|
|
|
341 |
* @param (callable($this): TUnlessReturnType)|null $default
|
|
|
342 |
* @return $this|TUnlessReturnType
|
|
|
343 |
*/
|
|
|
344 |
public function unless($value, callable $callback, callable $default = null);
|
|
|
345 |
|
|
|
346 |
/**
|
|
|
347 |
* Apply the callback unless the collection is empty.
|
|
|
348 |
*
|
|
|
349 |
* @template TUnlessEmptyReturnType
|
|
|
350 |
*
|
|
|
351 |
* @param callable($this): TUnlessEmptyReturnType $callback
|
|
|
352 |
* @param (callable($this): TUnlessEmptyReturnType)|null $default
|
|
|
353 |
* @return $this|TUnlessEmptyReturnType
|
|
|
354 |
*/
|
|
|
355 |
public function unlessEmpty(callable $callback, callable $default = null);
|
|
|
356 |
|
|
|
357 |
/**
|
|
|
358 |
* Apply the callback unless the collection is not empty.
|
|
|
359 |
*
|
|
|
360 |
* @template TUnlessNotEmptyReturnType
|
|
|
361 |
*
|
|
|
362 |
* @param callable($this): TUnlessNotEmptyReturnType $callback
|
|
|
363 |
* @param (callable($this): TUnlessNotEmptyReturnType)|null $default
|
|
|
364 |
* @return $this|TUnlessNotEmptyReturnType
|
|
|
365 |
*/
|
|
|
366 |
public function unlessNotEmpty(callable $callback, callable $default = null);
|
|
|
367 |
|
|
|
368 |
/**
|
|
|
369 |
* Filter items by the given key value pair.
|
|
|
370 |
*
|
|
|
371 |
* @param string $key
|
|
|
372 |
* @param mixed $operator
|
|
|
373 |
* @param mixed $value
|
|
|
374 |
* @return static
|
|
|
375 |
*/
|
|
|
376 |
public function where($key, $operator = null, $value = null);
|
|
|
377 |
|
|
|
378 |
/**
|
|
|
379 |
* Filter items where the value for the given key is null.
|
|
|
380 |
*
|
|
|
381 |
* @param string|null $key
|
|
|
382 |
* @return static
|
|
|
383 |
*/
|
|
|
384 |
public function whereNull($key = null);
|
|
|
385 |
|
|
|
386 |
/**
|
|
|
387 |
* Filter items where the value for the given key is not null.
|
|
|
388 |
*
|
|
|
389 |
* @param string|null $key
|
|
|
390 |
* @return static
|
|
|
391 |
*/
|
|
|
392 |
public function whereNotNull($key = null);
|
|
|
393 |
|
|
|
394 |
/**
|
|
|
395 |
* Filter items by the given key value pair using strict comparison.
|
|
|
396 |
*
|
|
|
397 |
* @param string $key
|
|
|
398 |
* @param mixed $value
|
|
|
399 |
* @return static
|
|
|
400 |
*/
|
|
|
401 |
public function whereStrict($key, $value);
|
|
|
402 |
|
|
|
403 |
/**
|
|
|
404 |
* Filter items by the given key value pair.
|
|
|
405 |
*
|
|
|
406 |
* @param string $key
|
|
|
407 |
* @param \Illuminate\Contracts\Support\Arrayable|iterable $values
|
|
|
408 |
* @param bool $strict
|
|
|
409 |
* @return static
|
|
|
410 |
*/
|
|
|
411 |
public function whereIn($key, $values, $strict = false);
|
|
|
412 |
|
|
|
413 |
/**
|
|
|
414 |
* Filter items by the given key value pair using strict comparison.
|
|
|
415 |
*
|
|
|
416 |
* @param string $key
|
|
|
417 |
* @param \Illuminate\Contracts\Support\Arrayable|iterable $values
|
|
|
418 |
* @return static
|
|
|
419 |
*/
|
|
|
420 |
public function whereInStrict($key, $values);
|
|
|
421 |
|
|
|
422 |
/**
|
|
|
423 |
* Filter items such that the value of the given key is between the given values.
|
|
|
424 |
*
|
|
|
425 |
* @param string $key
|
|
|
426 |
* @param \Illuminate\Contracts\Support\Arrayable|iterable $values
|
|
|
427 |
* @return static
|
|
|
428 |
*/
|
|
|
429 |
public function whereBetween($key, $values);
|
|
|
430 |
|
|
|
431 |
/**
|
|
|
432 |
* Filter items such that the value of the given key is not between the given values.
|
|
|
433 |
*
|
|
|
434 |
* @param string $key
|
|
|
435 |
* @param \Illuminate\Contracts\Support\Arrayable|iterable $values
|
|
|
436 |
* @return static
|
|
|
437 |
*/
|
|
|
438 |
public function whereNotBetween($key, $values);
|
|
|
439 |
|
|
|
440 |
/**
|
|
|
441 |
* Filter items by the given key value pair.
|
|
|
442 |
*
|
|
|
443 |
* @param string $key
|
|
|
444 |
* @param \Illuminate\Contracts\Support\Arrayable|iterable $values
|
|
|
445 |
* @param bool $strict
|
|
|
446 |
* @return static
|
|
|
447 |
*/
|
|
|
448 |
public function whereNotIn($key, $values, $strict = false);
|
|
|
449 |
|
|
|
450 |
/**
|
|
|
451 |
* Filter items by the given key value pair using strict comparison.
|
|
|
452 |
*
|
|
|
453 |
* @param string $key
|
|
|
454 |
* @param \Illuminate\Contracts\Support\Arrayable|iterable $values
|
|
|
455 |
* @return static
|
|
|
456 |
*/
|
|
|
457 |
public function whereNotInStrict($key, $values);
|
|
|
458 |
|
|
|
459 |
/**
|
|
|
460 |
* Filter the items, removing any items that don't match the given type(s).
|
|
|
461 |
*
|
|
|
462 |
* @template TWhereInstanceOf
|
|
|
463 |
*
|
|
|
464 |
* @param class-string<TWhereInstanceOf>|array<array-key, class-string<TWhereInstanceOf>> $type
|
|
|
465 |
* @return static<TKey, TWhereInstanceOf>
|
|
|
466 |
*/
|
|
|
467 |
public function whereInstanceOf($type);
|
|
|
468 |
|
|
|
469 |
/**
|
|
|
470 |
* Get the first item from the enumerable passing the given truth test.
|
|
|
471 |
*
|
|
|
472 |
* @template TFirstDefault
|
|
|
473 |
*
|
|
|
474 |
* @param (callable(TValue,TKey): bool)|null $callback
|
|
|
475 |
* @param TFirstDefault|(\Closure(): TFirstDefault) $default
|
|
|
476 |
* @return TValue|TFirstDefault
|
|
|
477 |
*/
|
|
|
478 |
public function first(callable $callback = null, $default = null);
|
|
|
479 |
|
|
|
480 |
/**
|
|
|
481 |
* Get the first item by the given key value pair.
|
|
|
482 |
*
|
|
|
483 |
* @param string $key
|
|
|
484 |
* @param mixed $operator
|
|
|
485 |
* @param mixed $value
|
|
|
486 |
* @return TValue|null
|
|
|
487 |
*/
|
|
|
488 |
public function firstWhere($key, $operator = null, $value = null);
|
|
|
489 |
|
|
|
490 |
/**
|
|
|
491 |
* Get a flattened array of the items in the collection.
|
|
|
492 |
*
|
|
|
493 |
* @param int $depth
|
|
|
494 |
* @return static
|
|
|
495 |
*/
|
|
|
496 |
public function flatten($depth = INF);
|
|
|
497 |
|
|
|
498 |
/**
|
|
|
499 |
* Flip the values with their keys.
|
|
|
500 |
*
|
|
|
501 |
* @return static<TValue, TKey>
|
|
|
502 |
*/
|
|
|
503 |
public function flip();
|
|
|
504 |
|
|
|
505 |
/**
|
|
|
506 |
* Get an item from the collection by key.
|
|
|
507 |
*
|
|
|
508 |
* @template TGetDefault
|
|
|
509 |
*
|
|
|
510 |
* @param TKey $key
|
|
|
511 |
* @param TGetDefault|(\Closure(): TGetDefault) $default
|
|
|
512 |
* @return TValue|TGetDefault
|
|
|
513 |
*/
|
|
|
514 |
public function get($key, $default = null);
|
|
|
515 |
|
|
|
516 |
/**
|
|
|
517 |
* Group an associative array by a field or using a callback.
|
|
|
518 |
*
|
|
|
519 |
* @param (callable(TValue, TKey): array-key)|array|string $groupBy
|
|
|
520 |
* @param bool $preserveKeys
|
|
|
521 |
* @return static<array-key, static<array-key, TValue>>
|
|
|
522 |
*/
|
|
|
523 |
public function groupBy($groupBy, $preserveKeys = false);
|
|
|
524 |
|
|
|
525 |
/**
|
|
|
526 |
* Key an associative array by a field or using a callback.
|
|
|
527 |
*
|
|
|
528 |
* @param (callable(TValue, TKey): array-key)|array|string $keyBy
|
|
|
529 |
* @return static<array-key, TValue>
|
|
|
530 |
*/
|
|
|
531 |
public function keyBy($keyBy);
|
|
|
532 |
|
|
|
533 |
/**
|
|
|
534 |
* Determine if an item exists in the collection by key.
|
|
|
535 |
*
|
|
|
536 |
* @param TKey|array<array-key, TKey> $key
|
|
|
537 |
* @return bool
|
|
|
538 |
*/
|
|
|
539 |
public function has($key);
|
|
|
540 |
|
|
|
541 |
/**
|
|
|
542 |
* Determine if any of the keys exist in the collection.
|
|
|
543 |
*
|
|
|
544 |
* @param mixed $key
|
|
|
545 |
* @return bool
|
|
|
546 |
*/
|
|
|
547 |
public function hasAny($key);
|
|
|
548 |
|
|
|
549 |
/**
|
|
|
550 |
* Concatenate values of a given key as a string.
|
|
|
551 |
*
|
|
|
552 |
* @param string $value
|
|
|
553 |
* @param string|null $glue
|
|
|
554 |
* @return string
|
|
|
555 |
*/
|
|
|
556 |
public function implode($value, $glue = null);
|
|
|
557 |
|
|
|
558 |
/**
|
|
|
559 |
* Intersect the collection with the given items.
|
|
|
560 |
*
|
|
|
561 |
* @param \Illuminate\Contracts\Support\Arrayable<TKey, TValue>|iterable<TKey, TValue> $items
|
|
|
562 |
* @return static
|
|
|
563 |
*/
|
|
|
564 |
public function intersect($items);
|
|
|
565 |
|
|
|
566 |
/**
|
|
|
567 |
* Intersect the collection with the given items by key.
|
|
|
568 |
*
|
|
|
569 |
* @param \Illuminate\Contracts\Support\Arrayable<TKey, TValue>|iterable<TKey, TValue> $items
|
|
|
570 |
* @return static
|
|
|
571 |
*/
|
|
|
572 |
public function intersectByKeys($items);
|
|
|
573 |
|
|
|
574 |
/**
|
|
|
575 |
* Determine if the collection is empty or not.
|
|
|
576 |
*
|
|
|
577 |
* @return bool
|
|
|
578 |
*/
|
|
|
579 |
public function isEmpty();
|
|
|
580 |
|
|
|
581 |
/**
|
|
|
582 |
* Determine if the collection is not empty.
|
|
|
583 |
*
|
|
|
584 |
* @return bool
|
|
|
585 |
*/
|
|
|
586 |
public function isNotEmpty();
|
|
|
587 |
|
|
|
588 |
/**
|
|
|
589 |
* Determine if the collection contains a single item.
|
|
|
590 |
*
|
|
|
591 |
* @return bool
|
|
|
592 |
*/
|
|
|
593 |
public function containsOneItem();
|
|
|
594 |
|
|
|
595 |
/**
|
|
|
596 |
* Join all items from the collection using a string. The final items can use a separate glue string.
|
|
|
597 |
*
|
|
|
598 |
* @param string $glue
|
|
|
599 |
* @param string $finalGlue
|
|
|
600 |
* @return string
|
|
|
601 |
*/
|
|
|
602 |
public function join($glue, $finalGlue = '');
|
|
|
603 |
|
|
|
604 |
/**
|
|
|
605 |
* Get the keys of the collection items.
|
|
|
606 |
*
|
|
|
607 |
* @return static<int, TKey>
|
|
|
608 |
*/
|
|
|
609 |
public function keys();
|
|
|
610 |
|
|
|
611 |
/**
|
|
|
612 |
* Get the last item from the collection.
|
|
|
613 |
*
|
|
|
614 |
* @template TLastDefault
|
|
|
615 |
*
|
|
|
616 |
* @param (callable(TValue, TKey): bool)|null $callback
|
|
|
617 |
* @param TLastDefault|(\Closure(): TLastDefault) $default
|
|
|
618 |
* @return TValue|TLastDefault
|
|
|
619 |
*/
|
|
|
620 |
public function last(callable $callback = null, $default = null);
|
|
|
621 |
|
|
|
622 |
/**
|
|
|
623 |
* Run a map over each of the items.
|
|
|
624 |
*
|
|
|
625 |
* @template TMapValue
|
|
|
626 |
*
|
|
|
627 |
* @param callable(TValue, TKey): TMapValue $callback
|
|
|
628 |
* @return static<TKey, TMapValue>
|
|
|
629 |
*/
|
|
|
630 |
public function map(callable $callback);
|
|
|
631 |
|
|
|
632 |
/**
|
|
|
633 |
* Run a map over each nested chunk of items.
|
|
|
634 |
*
|
|
|
635 |
* @param callable $callback
|
|
|
636 |
* @return static
|
|
|
637 |
*/
|
|
|
638 |
public function mapSpread(callable $callback);
|
|
|
639 |
|
|
|
640 |
/**
|
|
|
641 |
* Run a dictionary map over the items.
|
|
|
642 |
*
|
|
|
643 |
* The callback should return an associative array with a single key/value pair.
|
|
|
644 |
*
|
|
|
645 |
* @template TMapToDictionaryKey of array-key
|
|
|
646 |
* @template TMapToDictionaryValue
|
|
|
647 |
*
|
|
|
648 |
* @param callable(TValue, TKey): array<TMapToDictionaryKey, TMapToDictionaryValue> $callback
|
|
|
649 |
* @return static<TMapToDictionaryKey, array<int, TMapToDictionaryValue>>
|
|
|
650 |
*/
|
|
|
651 |
public function mapToDictionary(callable $callback);
|
|
|
652 |
|
|
|
653 |
/**
|
|
|
654 |
* Run a grouping map over the items.
|
|
|
655 |
*
|
|
|
656 |
* The callback should return an associative array with a single key/value pair.
|
|
|
657 |
*
|
|
|
658 |
* @template TMapToGroupsKey of array-key
|
|
|
659 |
* @template TMapToGroupsValue
|
|
|
660 |
*
|
|
|
661 |
* @param callable(TValue, TKey): array<TMapToGroupsKey, TMapToGroupsValue> $callback
|
|
|
662 |
* @return static<TMapToGroupsKey, static<int, TMapToGroupsValue>>
|
|
|
663 |
*/
|
|
|
664 |
public function mapToGroups(callable $callback);
|
|
|
665 |
|
|
|
666 |
/**
|
|
|
667 |
* Run an associative map over each of the items.
|
|
|
668 |
*
|
|
|
669 |
* The callback should return an associative array with a single key/value pair.
|
|
|
670 |
*
|
|
|
671 |
* @template TMapWithKeysKey of array-key
|
|
|
672 |
* @template TMapWithKeysValue
|
|
|
673 |
*
|
|
|
674 |
* @param callable(TValue, TKey): array<TMapWithKeysKey, TMapWithKeysValue> $callback
|
|
|
675 |
* @return static<TMapWithKeysKey, TMapWithKeysValue>
|
|
|
676 |
*/
|
|
|
677 |
public function mapWithKeys(callable $callback);
|
|
|
678 |
|
|
|
679 |
/**
|
|
|
680 |
* Map a collection and flatten the result by a single level.
|
|
|
681 |
*
|
|
|
682 |
* @template TFlatMapKey of array-key
|
|
|
683 |
* @template TFlatMapValue
|
|
|
684 |
*
|
|
|
685 |
* @param callable(TValue, TKey): (\Illuminate\Support\Collection<TFlatMapKey, TFlatMapValue>|array<TFlatMapKey, TFlatMapValue>) $callback
|
|
|
686 |
* @return static<TFlatMapKey, TFlatMapValue>
|
|
|
687 |
*/
|
|
|
688 |
public function flatMap(callable $callback);
|
|
|
689 |
|
|
|
690 |
/**
|
|
|
691 |
* Map the values into a new class.
|
|
|
692 |
*
|
|
|
693 |
* @template TMapIntoValue
|
|
|
694 |
*
|
|
|
695 |
* @param class-string<TMapIntoValue> $class
|
|
|
696 |
* @return static<TKey, TMapIntoValue>
|
|
|
697 |
*/
|
|
|
698 |
public function mapInto($class);
|
|
|
699 |
|
|
|
700 |
/**
|
|
|
701 |
* Merge the collection with the given items.
|
|
|
702 |
*
|
|
|
703 |
* @param \Illuminate\Contracts\Support\Arrayable<TKey, TValue>|iterable<TKey, TValue> $items
|
|
|
704 |
* @return static
|
|
|
705 |
*/
|
|
|
706 |
public function merge($items);
|
|
|
707 |
|
|
|
708 |
/**
|
|
|
709 |
* Recursively merge the collection with the given items.
|
|
|
710 |
*
|
|
|
711 |
* @template TMergeRecursiveValue
|
|
|
712 |
*
|
|
|
713 |
* @param \Illuminate\Contracts\Support\Arrayable<TKey, TMergeRecursiveValue>|iterable<TKey, TMergeRecursiveValue> $items
|
|
|
714 |
* @return static<TKey, TValue|TMergeRecursiveValue>
|
|
|
715 |
*/
|
|
|
716 |
public function mergeRecursive($items);
|
|
|
717 |
|
|
|
718 |
/**
|
|
|
719 |
* Create a collection by using this collection for keys and another for its values.
|
|
|
720 |
*
|
|
|
721 |
* @template TCombineValue
|
|
|
722 |
*
|
|
|
723 |
* @param \Illuminate\Contracts\Support\Arrayable<array-key, TCombineValue>|iterable<array-key, TCombineValue> $values
|
|
|
724 |
* @return static<TValue, TCombineValue>
|
|
|
725 |
*/
|
|
|
726 |
public function combine($values);
|
|
|
727 |
|
|
|
728 |
/**
|
|
|
729 |
* Union the collection with the given items.
|
|
|
730 |
*
|
|
|
731 |
* @param \Illuminate\Contracts\Support\Arrayable<TKey, TValue>|iterable<TKey, TValue> $items
|
|
|
732 |
* @return static
|
|
|
733 |
*/
|
|
|
734 |
public function union($items);
|
|
|
735 |
|
|
|
736 |
/**
|
|
|
737 |
* Get the min value of a given key.
|
|
|
738 |
*
|
|
|
739 |
* @param (callable(TValue):mixed)|string|null $callback
|
|
|
740 |
* @return mixed
|
|
|
741 |
*/
|
|
|
742 |
public function min($callback = null);
|
|
|
743 |
|
|
|
744 |
/**
|
|
|
745 |
* Get the max value of a given key.
|
|
|
746 |
*
|
|
|
747 |
* @param (callable(TValue):mixed)|string|null $callback
|
|
|
748 |
* @return mixed
|
|
|
749 |
*/
|
|
|
750 |
public function max($callback = null);
|
|
|
751 |
|
|
|
752 |
/**
|
|
|
753 |
* Create a new collection consisting of every n-th element.
|
|
|
754 |
*
|
|
|
755 |
* @param int $step
|
|
|
756 |
* @param int $offset
|
|
|
757 |
* @return static
|
|
|
758 |
*/
|
|
|
759 |
public function nth($step, $offset = 0);
|
|
|
760 |
|
|
|
761 |
/**
|
|
|
762 |
* Get the items with the specified keys.
|
|
|
763 |
*
|
|
|
764 |
* @param \Illuminate\Support\Enumerable<array-key, TKey>|array<array-key, TKey>|string $keys
|
|
|
765 |
* @return static
|
|
|
766 |
*/
|
|
|
767 |
public function only($keys);
|
|
|
768 |
|
|
|
769 |
/**
|
|
|
770 |
* "Paginate" the collection by slicing it into a smaller collection.
|
|
|
771 |
*
|
|
|
772 |
* @param int $page
|
|
|
773 |
* @param int $perPage
|
|
|
774 |
* @return static
|
|
|
775 |
*/
|
|
|
776 |
public function forPage($page, $perPage);
|
|
|
777 |
|
|
|
778 |
/**
|
|
|
779 |
* Partition the collection into two arrays using the given callback or key.
|
|
|
780 |
*
|
|
|
781 |
* @param (callable(TValue, TKey): bool)|TValue|string $key
|
|
|
782 |
* @param mixed $operator
|
|
|
783 |
* @param mixed $value
|
|
|
784 |
* @return static<int<0, 1>, static<TKey, TValue>>
|
|
|
785 |
*/
|
|
|
786 |
public function partition($key, $operator = null, $value = null);
|
|
|
787 |
|
|
|
788 |
/**
|
|
|
789 |
* Push all of the given items onto the collection.
|
|
|
790 |
*
|
|
|
791 |
* @param iterable<array-key, TValue> $source
|
|
|
792 |
* @return static
|
|
|
793 |
*/
|
|
|
794 |
public function concat($source);
|
|
|
795 |
|
|
|
796 |
/**
|
|
|
797 |
* Get one or a specified number of items randomly from the collection.
|
|
|
798 |
*
|
|
|
799 |
* @param int|null $number
|
|
|
800 |
* @return static<int, TValue>|TValue
|
|
|
801 |
*
|
|
|
802 |
* @throws \InvalidArgumentException
|
|
|
803 |
*/
|
|
|
804 |
public function random($number = null);
|
|
|
805 |
|
|
|
806 |
/**
|
|
|
807 |
* Reduce the collection to a single value.
|
|
|
808 |
*
|
|
|
809 |
* @template TReduceInitial
|
|
|
810 |
* @template TReduceReturnType
|
|
|
811 |
*
|
|
|
812 |
* @param callable(TReduceInitial|TReduceReturnType, TValue, TKey): TReduceReturnType $callback
|
|
|
813 |
* @param TReduceInitial $initial
|
|
|
814 |
* @return TReduceReturnType
|
|
|
815 |
*/
|
|
|
816 |
public function reduce(callable $callback, $initial = null);
|
|
|
817 |
|
|
|
818 |
/**
|
|
|
819 |
* Reduce the collection to multiple aggregate values.
|
|
|
820 |
*
|
|
|
821 |
* @param callable $callback
|
|
|
822 |
* @param mixed ...$initial
|
|
|
823 |
* @return array
|
|
|
824 |
*
|
|
|
825 |
* @throws \UnexpectedValueException
|
|
|
826 |
*/
|
|
|
827 |
public function reduceSpread(callable $callback, ...$initial);
|
|
|
828 |
|
|
|
829 |
/**
|
|
|
830 |
* Replace the collection items with the given items.
|
|
|
831 |
*
|
|
|
832 |
* @param \Illuminate\Contracts\Support\Arrayable<TKey, TValue>|iterable<TKey, TValue> $items
|
|
|
833 |
* @return static
|
|
|
834 |
*/
|
|
|
835 |
public function replace($items);
|
|
|
836 |
|
|
|
837 |
/**
|
|
|
838 |
* Recursively replace the collection items with the given items.
|
|
|
839 |
*
|
|
|
840 |
* @param \Illuminate\Contracts\Support\Arrayable<TKey, TValue>|iterable<TKey, TValue> $items
|
|
|
841 |
* @return static
|
|
|
842 |
*/
|
|
|
843 |
public function replaceRecursive($items);
|
|
|
844 |
|
|
|
845 |
/**
|
|
|
846 |
* Reverse items order.
|
|
|
847 |
*
|
|
|
848 |
* @return static
|
|
|
849 |
*/
|
|
|
850 |
public function reverse();
|
|
|
851 |
|
|
|
852 |
/**
|
|
|
853 |
* Search the collection for a given value and return the corresponding key if successful.
|
|
|
854 |
*
|
|
|
855 |
* @param TValue|callable(TValue,TKey): bool $value
|
|
|
856 |
* @param bool $strict
|
|
|
857 |
* @return TKey|bool
|
|
|
858 |
*/
|
|
|
859 |
public function search($value, $strict = false);
|
|
|
860 |
|
|
|
861 |
/**
|
|
|
862 |
* Shuffle the items in the collection.
|
|
|
863 |
*
|
|
|
864 |
* @param int|null $seed
|
|
|
865 |
* @return static
|
|
|
866 |
*/
|
|
|
867 |
public function shuffle($seed = null);
|
|
|
868 |
|
|
|
869 |
/**
|
|
|
870 |
* Create chunks representing a "sliding window" view of the items in the collection.
|
|
|
871 |
*
|
|
|
872 |
* @param int $size
|
|
|
873 |
* @param int $step
|
|
|
874 |
* @return static<int, static>
|
|
|
875 |
*/
|
|
|
876 |
public function sliding($size = 2, $step = 1);
|
|
|
877 |
|
|
|
878 |
/**
|
|
|
879 |
* Skip the first {$count} items.
|
|
|
880 |
*
|
|
|
881 |
* @param int $count
|
|
|
882 |
* @return static
|
|
|
883 |
*/
|
|
|
884 |
public function skip($count);
|
|
|
885 |
|
|
|
886 |
/**
|
|
|
887 |
* Skip items in the collection until the given condition is met.
|
|
|
888 |
*
|
|
|
889 |
* @param TValue|callable(TValue,TKey): bool $value
|
|
|
890 |
* @return static
|
|
|
891 |
*/
|
|
|
892 |
public function skipUntil($value);
|
|
|
893 |
|
|
|
894 |
/**
|
|
|
895 |
* Skip items in the collection while the given condition is met.
|
|
|
896 |
*
|
|
|
897 |
* @param TValue|callable(TValue,TKey): bool $value
|
|
|
898 |
* @return static
|
|
|
899 |
*/
|
|
|
900 |
public function skipWhile($value);
|
|
|
901 |
|
|
|
902 |
/**
|
|
|
903 |
* Get a slice of items from the enumerable.
|
|
|
904 |
*
|
|
|
905 |
* @param int $offset
|
|
|
906 |
* @param int|null $length
|
|
|
907 |
* @return static
|
|
|
908 |
*/
|
|
|
909 |
public function slice($offset, $length = null);
|
|
|
910 |
|
|
|
911 |
/**
|
|
|
912 |
* Split a collection into a certain number of groups.
|
|
|
913 |
*
|
|
|
914 |
* @param int $numberOfGroups
|
|
|
915 |
* @return static<int, static>
|
|
|
916 |
*/
|
|
|
917 |
public function split($numberOfGroups);
|
|
|
918 |
|
|
|
919 |
/**
|
|
|
920 |
* Get the first item in the collection, but only if exactly one item exists. Otherwise, throw an exception.
|
|
|
921 |
*
|
|
|
922 |
* @param (callable(TValue, TKey): bool)|string $key
|
|
|
923 |
* @param mixed $operator
|
|
|
924 |
* @param mixed $value
|
|
|
925 |
* @return TValue
|
|
|
926 |
*
|
|
|
927 |
* @throws \Illuminate\Support\ItemNotFoundException
|
|
|
928 |
* @throws \Illuminate\Support\MultipleItemsFoundException
|
|
|
929 |
*/
|
|
|
930 |
public function sole($key = null, $operator = null, $value = null);
|
|
|
931 |
|
|
|
932 |
/**
|
|
|
933 |
* Get the first item in the collection but throw an exception if no matching items exist.
|
|
|
934 |
*
|
|
|
935 |
* @param (callable(TValue, TKey): bool)|string $key
|
|
|
936 |
* @param mixed $operator
|
|
|
937 |
* @param mixed $value
|
|
|
938 |
* @return TValue
|
|
|
939 |
*
|
|
|
940 |
* @throws \Illuminate\Support\ItemNotFoundException
|
|
|
941 |
*/
|
|
|
942 |
public function firstOrFail($key = null, $operator = null, $value = null);
|
|
|
943 |
|
|
|
944 |
/**
|
|
|
945 |
* Chunk the collection into chunks of the given size.
|
|
|
946 |
*
|
|
|
947 |
* @param int $size
|
|
|
948 |
* @return static<int, static>
|
|
|
949 |
*/
|
|
|
950 |
public function chunk($size);
|
|
|
951 |
|
|
|
952 |
/**
|
|
|
953 |
* Chunk the collection into chunks with a callback.
|
|
|
954 |
*
|
|
|
955 |
* @param callable(TValue, TKey, static<int, TValue>): bool $callback
|
|
|
956 |
* @return static<int, static<int, TValue>>
|
|
|
957 |
*/
|
|
|
958 |
public function chunkWhile(callable $callback);
|
|
|
959 |
|
|
|
960 |
/**
|
|
|
961 |
* Split a collection into a certain number of groups, and fill the first groups completely.
|
|
|
962 |
*
|
|
|
963 |
* @param int $numberOfGroups
|
|
|
964 |
* @return static<int, static>
|
|
|
965 |
*/
|
|
|
966 |
public function splitIn($numberOfGroups);
|
|
|
967 |
|
|
|
968 |
/**
|
|
|
969 |
* Sort through each item with a callback.
|
|
|
970 |
*
|
|
|
971 |
* @param (callable(TValue, TValue): int)|null|int $callback
|
|
|
972 |
* @return static
|
|
|
973 |
*/
|
|
|
974 |
public function sort($callback = null);
|
|
|
975 |
|
|
|
976 |
/**
|
|
|
977 |
* Sort items in descending order.
|
|
|
978 |
*
|
|
|
979 |
* @param int $options
|
|
|
980 |
* @return static
|
|
|
981 |
*/
|
|
|
982 |
public function sortDesc($options = SORT_REGULAR);
|
|
|
983 |
|
|
|
984 |
/**
|
|
|
985 |
* Sort the collection using the given callback.
|
|
|
986 |
*
|
|
|
987 |
* @param array<array-key, (callable(TValue, TValue): mixed)|(callable(TValue, TKey): mixed)|string|array{string, string}>|(callable(TValue, TKey): mixed)|string $callback
|
|
|
988 |
* @param int $options
|
|
|
989 |
* @param bool $descending
|
|
|
990 |
* @return static
|
|
|
991 |
*/
|
|
|
992 |
public function sortBy($callback, $options = SORT_REGULAR, $descending = false);
|
|
|
993 |
|
|
|
994 |
/**
|
|
|
995 |
* Sort the collection in descending order using the given callback.
|
|
|
996 |
*
|
|
|
997 |
* @param array<array-key, (callable(TValue, TValue): mixed)|(callable(TValue, TKey): mixed)|string|array{string, string}>|(callable(TValue, TKey): mixed)|string $callback
|
|
|
998 |
* @param int $options
|
|
|
999 |
* @return static
|
|
|
1000 |
*/
|
|
|
1001 |
public function sortByDesc($callback, $options = SORT_REGULAR);
|
|
|
1002 |
|
|
|
1003 |
/**
|
|
|
1004 |
* Sort the collection keys.
|
|
|
1005 |
*
|
|
|
1006 |
* @param int $options
|
|
|
1007 |
* @param bool $descending
|
|
|
1008 |
* @return static
|
|
|
1009 |
*/
|
|
|
1010 |
public function sortKeys($options = SORT_REGULAR, $descending = false);
|
|
|
1011 |
|
|
|
1012 |
/**
|
|
|
1013 |
* Sort the collection keys in descending order.
|
|
|
1014 |
*
|
|
|
1015 |
* @param int $options
|
|
|
1016 |
* @return static
|
|
|
1017 |
*/
|
|
|
1018 |
public function sortKeysDesc($options = SORT_REGULAR);
|
|
|
1019 |
|
|
|
1020 |
/**
|
|
|
1021 |
* Sort the collection keys using a callback.
|
|
|
1022 |
*
|
|
|
1023 |
* @param callable(TKey, TKey): int $callback
|
|
|
1024 |
* @return static
|
|
|
1025 |
*/
|
|
|
1026 |
public function sortKeysUsing(callable $callback);
|
|
|
1027 |
|
|
|
1028 |
/**
|
|
|
1029 |
* Get the sum of the given values.
|
|
|
1030 |
*
|
|
|
1031 |
* @param (callable(TValue): mixed)|string|null $callback
|
|
|
1032 |
* @return mixed
|
|
|
1033 |
*/
|
|
|
1034 |
public function sum($callback = null);
|
|
|
1035 |
|
|
|
1036 |
/**
|
|
|
1037 |
* Take the first or last {$limit} items.
|
|
|
1038 |
*
|
|
|
1039 |
* @param int $limit
|
|
|
1040 |
* @return static
|
|
|
1041 |
*/
|
|
|
1042 |
public function take($limit);
|
|
|
1043 |
|
|
|
1044 |
/**
|
|
|
1045 |
* Take items in the collection until the given condition is met.
|
|
|
1046 |
*
|
|
|
1047 |
* @param TValue|callable(TValue,TKey): bool $value
|
|
|
1048 |
* @return static
|
|
|
1049 |
*/
|
|
|
1050 |
public function takeUntil($value);
|
|
|
1051 |
|
|
|
1052 |
/**
|
|
|
1053 |
* Take items in the collection while the given condition is met.
|
|
|
1054 |
*
|
|
|
1055 |
* @param TValue|callable(TValue,TKey): bool $value
|
|
|
1056 |
* @return static
|
|
|
1057 |
*/
|
|
|
1058 |
public function takeWhile($value);
|
|
|
1059 |
|
|
|
1060 |
/**
|
|
|
1061 |
* Pass the collection to the given callback and then return it.
|
|
|
1062 |
*
|
|
|
1063 |
* @param callable(TValue): mixed $callback
|
|
|
1064 |
* @return $this
|
|
|
1065 |
*/
|
|
|
1066 |
public function tap(callable $callback);
|
|
|
1067 |
|
|
|
1068 |
/**
|
|
|
1069 |
* Pass the enumerable to the given callback and return the result.
|
|
|
1070 |
*
|
|
|
1071 |
* @template TPipeReturnType
|
|
|
1072 |
*
|
|
|
1073 |
* @param callable($this): TPipeReturnType $callback
|
|
|
1074 |
* @return TPipeReturnType
|
|
|
1075 |
*/
|
|
|
1076 |
public function pipe(callable $callback);
|
|
|
1077 |
|
|
|
1078 |
/**
|
|
|
1079 |
* Pass the collection into a new class.
|
|
|
1080 |
*
|
|
|
1081 |
* @param class-string $class
|
|
|
1082 |
* @return mixed
|
|
|
1083 |
*/
|
|
|
1084 |
public function pipeInto($class);
|
|
|
1085 |
|
|
|
1086 |
/**
|
|
|
1087 |
* Pass the collection through a series of callable pipes and return the result.
|
|
|
1088 |
*
|
|
|
1089 |
* @param array<callable> $pipes
|
|
|
1090 |
* @return mixed
|
|
|
1091 |
*/
|
|
|
1092 |
public function pipeThrough($pipes);
|
|
|
1093 |
|
|
|
1094 |
/**
|
|
|
1095 |
* Get the values of a given key.
|
|
|
1096 |
*
|
|
|
1097 |
* @param string|array<array-key, string> $value
|
|
|
1098 |
* @param string|null $key
|
|
|
1099 |
* @return static<int, mixed>
|
|
|
1100 |
*/
|
|
|
1101 |
public function pluck($value, $key = null);
|
|
|
1102 |
|
|
|
1103 |
/**
|
|
|
1104 |
* Create a collection of all elements that do not pass a given truth test.
|
|
|
1105 |
*
|
|
|
1106 |
* @param (callable(TValue, TKey): bool)|bool|TValue $callback
|
|
|
1107 |
* @return static
|
|
|
1108 |
*/
|
|
|
1109 |
public function reject($callback = true);
|
|
|
1110 |
|
|
|
1111 |
/**
|
|
|
1112 |
* Convert a flatten "dot" notation array into an expanded array.
|
|
|
1113 |
*
|
|
|
1114 |
* @return static
|
|
|
1115 |
*/
|
|
|
1116 |
public function undot();
|
|
|
1117 |
|
|
|
1118 |
/**
|
|
|
1119 |
* Return only unique items from the collection array.
|
|
|
1120 |
*
|
|
|
1121 |
* @param (callable(TValue, TKey): mixed)|string|null $key
|
|
|
1122 |
* @param bool $strict
|
|
|
1123 |
* @return static
|
|
|
1124 |
*/
|
|
|
1125 |
public function unique($key = null, $strict = false);
|
|
|
1126 |
|
|
|
1127 |
/**
|
|
|
1128 |
* Return only unique items from the collection array using strict comparison.
|
|
|
1129 |
*
|
|
|
1130 |
* @param (callable(TValue, TKey): mixed)|string|null $key
|
|
|
1131 |
* @return static
|
|
|
1132 |
*/
|
|
|
1133 |
public function uniqueStrict($key = null);
|
|
|
1134 |
|
|
|
1135 |
/**
|
|
|
1136 |
* Reset the keys on the underlying array.
|
|
|
1137 |
*
|
|
|
1138 |
* @return static<int, TValue>
|
|
|
1139 |
*/
|
|
|
1140 |
public function values();
|
|
|
1141 |
|
|
|
1142 |
/**
|
|
|
1143 |
* Pad collection to the specified length with a value.
|
|
|
1144 |
*
|
|
|
1145 |
* @template TPadValue
|
|
|
1146 |
*
|
|
|
1147 |
* @param int $size
|
|
|
1148 |
* @param TPadValue $value
|
|
|
1149 |
* @return static<int, TValue|TPadValue>
|
|
|
1150 |
*/
|
|
|
1151 |
public function pad($size, $value);
|
|
|
1152 |
|
|
|
1153 |
/**
|
|
|
1154 |
* Get the values iterator.
|
|
|
1155 |
*
|
|
|
1156 |
* @return \Traversable<TKey, TValue>
|
|
|
1157 |
*/
|
|
|
1158 |
public function getIterator(): Traversable;
|
|
|
1159 |
|
|
|
1160 |
/**
|
|
|
1161 |
* Count the number of items in the collection.
|
|
|
1162 |
*
|
|
|
1163 |
* @return int
|
|
|
1164 |
*/
|
|
|
1165 |
public function count(): int;
|
|
|
1166 |
|
|
|
1167 |
/**
|
|
|
1168 |
* Count the number of items in the collection by a field or using a callback.
|
|
|
1169 |
*
|
| 150 |
lars |
1170 |
* @param (callable(TValue, TKey): array-key)|string|null $countBy
|
| 148 |
lars |
1171 |
* @return static<array-key, int>
|
|
|
1172 |
*/
|
|
|
1173 |
public function countBy($countBy = null);
|
|
|
1174 |
|
|
|
1175 |
/**
|
|
|
1176 |
* Zip the collection together with one or more arrays.
|
|
|
1177 |
*
|
|
|
1178 |
* e.g. new Collection([1, 2, 3])->zip([4, 5, 6]);
|
|
|
1179 |
* => [[1, 4], [2, 5], [3, 6]]
|
|
|
1180 |
*
|
|
|
1181 |
* @template TZipValue
|
|
|
1182 |
*
|
|
|
1183 |
* @param \Illuminate\Contracts\Support\Arrayable<array-key, TZipValue>|iterable<array-key, TZipValue> ...$items
|
|
|
1184 |
* @return static<int, static<int, TValue|TZipValue>>
|
|
|
1185 |
*/
|
|
|
1186 |
public function zip($items);
|
|
|
1187 |
|
|
|
1188 |
/**
|
|
|
1189 |
* Collect the values into a collection.
|
|
|
1190 |
*
|
|
|
1191 |
* @return \Illuminate\Support\Collection<TKey, TValue>
|
|
|
1192 |
*/
|
|
|
1193 |
public function collect();
|
|
|
1194 |
|
|
|
1195 |
/**
|
|
|
1196 |
* Get the collection of items as a plain array.
|
|
|
1197 |
*
|
|
|
1198 |
* @return array<TKey, mixed>
|
|
|
1199 |
*/
|
|
|
1200 |
public function toArray();
|
|
|
1201 |
|
|
|
1202 |
/**
|
|
|
1203 |
* Convert the object into something JSON serializable.
|
|
|
1204 |
*
|
|
|
1205 |
* @return mixed
|
|
|
1206 |
*/
|
|
|
1207 |
public function jsonSerialize(): mixed;
|
|
|
1208 |
|
|
|
1209 |
/**
|
|
|
1210 |
* Get the collection of items as JSON.
|
|
|
1211 |
*
|
|
|
1212 |
* @param int $options
|
|
|
1213 |
* @return string
|
|
|
1214 |
*/
|
|
|
1215 |
public function toJson($options = 0);
|
|
|
1216 |
|
|
|
1217 |
/**
|
|
|
1218 |
* Get a CachingIterator instance.
|
|
|
1219 |
*
|
|
|
1220 |
* @param int $flags
|
|
|
1221 |
* @return \CachingIterator
|
|
|
1222 |
*/
|
|
|
1223 |
public function getCachingIterator($flags = CachingIterator::CALL_TOSTRING);
|
|
|
1224 |
|
|
|
1225 |
/**
|
|
|
1226 |
* Convert the collection to its string representation.
|
|
|
1227 |
*
|
|
|
1228 |
* @return string
|
|
|
1229 |
*/
|
|
|
1230 |
public function __toString();
|
|
|
1231 |
|
|
|
1232 |
/**
|
|
|
1233 |
* Indicate that the model's string representation should be escaped when __toString is invoked.
|
|
|
1234 |
*
|
|
|
1235 |
* @param bool $escape
|
|
|
1236 |
* @return $this
|
|
|
1237 |
*/
|
|
|
1238 |
public function escapeWhenCastingToString($escape = true);
|
|
|
1239 |
|
|
|
1240 |
/**
|
|
|
1241 |
* Add a method to the list of proxied methods.
|
|
|
1242 |
*
|
|
|
1243 |
* @param string $method
|
|
|
1244 |
* @return void
|
|
|
1245 |
*/
|
|
|
1246 |
public static function proxy($method);
|
|
|
1247 |
|
|
|
1248 |
/**
|
|
|
1249 |
* Dynamically access collection proxies.
|
|
|
1250 |
*
|
|
|
1251 |
* @param string $key
|
|
|
1252 |
* @return mixed
|
|
|
1253 |
*
|
|
|
1254 |
* @throws \Exception
|
|
|
1255 |
*/
|
|
|
1256 |
public function __get($key);
|
|
|
1257 |
}
|