|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace loophp\collection; |
|
6
|
|
|
|
|
7
|
|
|
use Closure; |
|
8
|
|
|
use Doctrine\Common\Collections\Criteria; |
|
9
|
|
|
use Generator; |
|
10
|
|
|
use loophp\collection\Contract\Collection as CollectionInterface; |
|
11
|
|
|
use loophp\collection\Contract\Operation; |
|
12
|
|
|
use Psr\Cache\CacheItemPoolInterface; |
|
13
|
|
|
use Traversable; |
|
14
|
|
|
|
|
15
|
|
|
use const INF; |
|
16
|
|
|
use const PHP_INT_MAX; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @template TKey |
|
20
|
|
|
* @template T |
|
21
|
|
|
* |
|
22
|
|
|
* @immutable |
|
23
|
|
|
* |
|
24
|
|
|
* @psalm-consistent-constructor |
|
25
|
|
|
* |
|
26
|
|
|
* @psalm-consistent-templates |
|
27
|
|
|
* |
|
28
|
|
|
* @implements \loophp\collection\Contract\Collection<TKey, T> |
|
29
|
|
|
*/ |
|
30
|
|
|
abstract class CollectionDecorator implements CollectionInterface |
|
31
|
|
|
{ |
|
32
|
|
|
/** |
|
33
|
|
|
* @param CollectionInterface<TKey, T> $innerCollection |
|
34
|
|
|
*/ |
|
35
|
349 |
|
public function __construct(protected CollectionInterface $innerCollection) {} |
|
36
|
|
|
|
|
37
|
5 |
|
public function all(bool $normalize = true): array |
|
38
|
|
|
{ |
|
39
|
5 |
|
return $this->innerCollection->all($normalize); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
1 |
|
public function append(mixed ...$items): static |
|
43
|
|
|
{ |
|
44
|
1 |
|
return new static($this->innerCollection->append(...$items)); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
3 |
|
public function apply(callable ...$callbacks): static |
|
48
|
|
|
{ |
|
49
|
3 |
|
return new static($this->innerCollection->apply(...$callbacks)); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
2 |
|
public function associate( |
|
53
|
|
|
?callable $callbackForKeys = null, |
|
54
|
|
|
?callable $callbackForValues = null |
|
55
|
|
|
): static { |
|
56
|
2 |
|
return new static($this->innerCollection->associate($callbackForKeys, $callbackForValues)); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
1 |
|
public function asyncMap(callable $callback): static |
|
60
|
|
|
{ |
|
61
|
1 |
|
return new static($this->innerCollection->asyncMap($callback)); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
1 |
|
public function asyncMapN(callable ...$callbacks): static |
|
65
|
|
|
{ |
|
66
|
1 |
|
return new static($this->innerCollection->asyncMapN(...$callbacks)); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
2 |
|
public function averages(): static |
|
70
|
|
|
{ |
|
71
|
2 |
|
return new static($this->innerCollection->averages()); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
1 |
|
public function cache(?CacheItemPoolInterface $cache = null): static |
|
75
|
|
|
{ |
|
76
|
1 |
|
return new static($this->innerCollection->cache($cache)); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
4 |
|
public function chunk(int ...$sizes): static |
|
80
|
|
|
{ |
|
81
|
4 |
|
return new static($this->innerCollection->chunk(...$sizes)); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
2 |
|
public function coalesce(): static |
|
85
|
|
|
{ |
|
86
|
2 |
|
return new static($this->innerCollection->coalesce()); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
2 |
|
public function collapse(): static |
|
90
|
|
|
{ |
|
91
|
2 |
|
return new static($this->innerCollection->collapse()); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
3 |
|
public function column(mixed $column): static |
|
95
|
|
|
{ |
|
96
|
3 |
|
return new static($this->innerCollection->column($column)); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
3 |
|
public function combinate(?int $length = null): static |
|
100
|
|
|
{ |
|
101
|
3 |
|
return new static($this->innerCollection->combinate($length)); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
3 |
|
public function combine(mixed ...$keys): static |
|
105
|
|
|
{ |
|
106
|
3 |
|
return new static($this->innerCollection->combine(...$keys)); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
2 |
|
public function compact(mixed ...$values): static |
|
110
|
|
|
{ |
|
111
|
2 |
|
return new static($this->innerCollection->compact(...$values)); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
5 |
|
public function compare(callable $comparator, $default = null): mixed |
|
115
|
|
|
{ |
|
116
|
5 |
|
return $this->innerCollection->compare($comparator, $default); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
5 |
|
public function contains(mixed ...$values): bool |
|
120
|
|
|
{ |
|
121
|
5 |
|
return $this->innerCollection->contains(...$values); |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
public function countIn(int &$counter): CollectionInterface |
|
125
|
|
|
{ |
|
126
|
|
|
$this->innerCollection->countIn($counter); |
|
127
|
|
|
|
|
128
|
|
|
return $this; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
3 |
|
public function current(int $index = 0, $default = null): mixed |
|
132
|
|
|
{ |
|
133
|
3 |
|
return $this->innerCollection->current($index, $default); |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
1 |
|
public function cycle(): static |
|
137
|
|
|
{ |
|
138
|
1 |
|
return new static($this->innerCollection->cycle()); |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
7 |
|
public function diff(mixed ...$values): static |
|
142
|
|
|
{ |
|
143
|
7 |
|
return new static($this->innerCollection->diff(...$values)); |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
2 |
|
public function diffKeys(mixed ...$keys): static |
|
147
|
|
|
{ |
|
148
|
2 |
|
return new static($this->innerCollection->diffKeys(...$keys)); |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
public function dispersion(): static |
|
152
|
|
|
{ |
|
153
|
|
|
return new static($this->innerCollection->dispersion()); |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
6 |
|
public function distinct(?callable $comparatorCallback = null, ?callable $accessorCallback = null): static |
|
157
|
|
|
{ |
|
158
|
6 |
|
return new static($this->innerCollection->distinct($comparatorCallback, $accessorCallback)); |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
2 |
|
public function drop(int $count): static |
|
162
|
|
|
{ |
|
163
|
2 |
|
return new static($this->innerCollection->drop($count)); |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
2 |
|
public function dropWhile(callable ...$callbacks): static |
|
167
|
|
|
{ |
|
168
|
2 |
|
return new static($this->innerCollection->dropWhile(...$callbacks)); |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
2 |
|
public function dump(string $name = '', int $size = 1, ?Closure $closure = null): static |
|
172
|
|
|
{ |
|
173
|
2 |
|
return new static($this->innerCollection->dump($name, $size, $closure)); |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
5 |
|
public function duplicate(?callable $comparatorCallback = null, ?callable $accessorCallback = null): static |
|
177
|
|
|
{ |
|
178
|
5 |
|
return new static($this->innerCollection->duplicate($comparatorCallback, $accessorCallback)); |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
1 |
|
public static function empty(): static |
|
182
|
|
|
{ |
|
183
|
1 |
|
return new static(Collection::empty()); |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
public function entropy(): static |
|
187
|
|
|
{ |
|
188
|
|
|
return new static($this->innerCollection->entropy()); |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
18 |
|
public function equals(iterable $other): bool |
|
192
|
|
|
{ |
|
193
|
18 |
|
return $this->innerCollection->equals($other); |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
8 |
|
public function every(callable ...$callbacks): bool |
|
197
|
|
|
{ |
|
198
|
8 |
|
return $this->innerCollection->every(...$callbacks); |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
1 |
|
public function explode(mixed ...$explodes): static |
|
202
|
|
|
{ |
|
203
|
1 |
|
return new static($this->innerCollection->explode(...$explodes)); |
|
204
|
|
|
} |
|
205
|
|
|
|
|
206
|
4 |
|
public function falsy(): bool |
|
207
|
|
|
{ |
|
208
|
4 |
|
return $this->innerCollection->falsy(); |
|
209
|
|
|
} |
|
210
|
|
|
|
|
211
|
4 |
|
public function filter(callable ...$callbacks): static |
|
212
|
|
|
{ |
|
213
|
4 |
|
return new static($this->innerCollection->filter(...$callbacks)); |
|
214
|
|
|
} |
|
215
|
|
|
|
|
216
|
5 |
|
public function find($default = null, callable ...$callbacks): mixed |
|
217
|
|
|
{ |
|
218
|
5 |
|
return $this->innerCollection->find($default, ...$callbacks); |
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
5 |
|
public function first($default = null): mixed |
|
222
|
|
|
{ |
|
223
|
5 |
|
return $this->innerCollection->first($default); |
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
7 |
|
public function flatMap(callable $callback): static |
|
227
|
|
|
{ |
|
228
|
7 |
|
return new static($this->innerCollection->flatMap($callback)); |
|
229
|
|
|
} |
|
230
|
|
|
|
|
231
|
3 |
|
public function flatten(int $depth = PHP_INT_MAX): static |
|
232
|
|
|
{ |
|
233
|
3 |
|
return new static($this->innerCollection->flatten($depth)); |
|
234
|
|
|
} |
|
235
|
|
|
|
|
236
|
2 |
|
public function flip(): static |
|
237
|
|
|
{ |
|
238
|
2 |
|
return new static($this->innerCollection->flip()); |
|
239
|
|
|
} |
|
240
|
|
|
|
|
241
|
4 |
|
public function foldLeft(callable $callback, $initial): mixed |
|
242
|
|
|
{ |
|
243
|
4 |
|
return $this->innerCollection->foldLeft($callback, $initial); |
|
244
|
|
|
} |
|
245
|
|
|
|
|
246
|
2 |
|
public function foldLeft1(callable $callback): mixed |
|
247
|
|
|
{ |
|
248
|
2 |
|
return $this->innerCollection->foldLeft1($callback); |
|
249
|
|
|
} |
|
250
|
|
|
|
|
251
|
1 |
|
public function foldRight(callable $callback, $initial): mixed |
|
252
|
|
|
{ |
|
253
|
1 |
|
return $this->innerCollection->foldRight($callback, $initial); |
|
254
|
|
|
} |
|
255
|
|
|
|
|
256
|
2 |
|
public function foldRight1(callable $callback): mixed |
|
257
|
|
|
{ |
|
258
|
2 |
|
return $this->innerCollection->foldRight1($callback); |
|
259
|
|
|
} |
|
260
|
|
|
|
|
261
|
1 |
|
public function forget(mixed ...$keys): static |
|
262
|
|
|
{ |
|
263
|
1 |
|
return new static($this->innerCollection->forget(...$keys)); |
|
264
|
|
|
} |
|
265
|
|
|
|
|
266
|
1 |
|
public function frequency(): static |
|
267
|
|
|
{ |
|
268
|
1 |
|
return new static($this->innerCollection->frequency()); |
|
269
|
|
|
} |
|
270
|
|
|
|
|
271
|
|
|
/** |
|
272
|
|
|
* @template UKey |
|
273
|
|
|
* @template U |
|
274
|
|
|
* |
|
275
|
|
|
* @param callable(mixed ...$parameters): iterable<UKey, U> $callable |
|
276
|
|
|
* @param iterable<int, mixed> $parameters |
|
277
|
|
|
* |
|
278
|
|
|
* @return static<UKey, U> |
|
279
|
|
|
*/ |
|
280
|
1 |
|
public static function fromCallable(callable $callable, iterable $parameters = []): static |
|
281
|
|
|
{ |
|
282
|
1 |
|
return new static(Collection::fromCallable($callable, $parameters)); |
|
283
|
|
|
} |
|
284
|
|
|
|
|
285
|
|
|
/** |
|
286
|
|
|
* @param Closure(resource): mixed $consumer |
|
287
|
|
|
*/ |
|
288
|
1 |
|
public static function fromFile(string $filepath, ?Closure $consumer = null): static |
|
289
|
|
|
{ |
|
290
|
1 |
|
return new static(Collection::fromFile($filepath, $consumer)); |
|
291
|
|
|
} |
|
292
|
|
|
|
|
293
|
1 |
|
public static function fromGenerator(Generator $generator): static |
|
294
|
|
|
{ |
|
295
|
1 |
|
return new static(Collection::fromGenerator($generator)); |
|
296
|
|
|
} |
|
297
|
|
|
|
|
298
|
|
|
/** |
|
299
|
|
|
* @template UKey |
|
300
|
|
|
* @template U |
|
301
|
|
|
* |
|
302
|
|
|
* @param iterable<UKey, U> $iterable |
|
303
|
|
|
* |
|
304
|
|
|
* @return static<UKey, U> |
|
305
|
|
|
*/ |
|
306
|
1 |
|
public static function fromIterable(iterable $iterable): static |
|
307
|
|
|
{ |
|
308
|
1 |
|
return new static(Collection::fromIterable($iterable)); |
|
309
|
|
|
} |
|
310
|
|
|
|
|
311
|
|
|
/** |
|
312
|
|
|
* @param resource $resource |
|
313
|
|
|
* |
|
314
|
|
|
* @return static<int, string> |
|
315
|
|
|
*/ |
|
316
|
1 |
|
public static function fromResource($resource): static |
|
317
|
|
|
{ |
|
318
|
1 |
|
return new static(Collection::fromResource($resource)); |
|
319
|
|
|
} |
|
320
|
|
|
|
|
321
|
1 |
|
public static function fromString(string $string, string $delimiter = ''): static |
|
322
|
|
|
{ |
|
323
|
1 |
|
return new static(Collection::fromString($string, $delimiter)); |
|
324
|
|
|
} |
|
325
|
|
|
|
|
326
|
2 |
|
public function get(mixed $key, $default = null): mixed |
|
327
|
|
|
{ |
|
328
|
2 |
|
return $this->innerCollection->get($key, $default); |
|
329
|
|
|
} |
|
330
|
|
|
|
|
331
|
|
|
/** |
|
332
|
|
|
* @return Traversable<TKey, T> |
|
333
|
|
|
*/ |
|
334
|
202 |
|
public function getIterator(): Traversable |
|
335
|
|
|
{ |
|
336
|
202 |
|
yield from $this->innerCollection->getIterator(); |
|
337
|
|
|
} |
|
338
|
|
|
|
|
339
|
3 |
|
public function group(): static |
|
340
|
|
|
{ |
|
341
|
3 |
|
return new static($this->innerCollection->group()); |
|
342
|
|
|
} |
|
343
|
|
|
|
|
344
|
2 |
|
public function groupBy(callable $callback): static |
|
345
|
|
|
{ |
|
346
|
2 |
|
return new static($this->innerCollection->groupBy($callback)); |
|
347
|
|
|
} |
|
348
|
|
|
|
|
349
|
8 |
|
public function has(callable ...$callbacks): bool |
|
350
|
|
|
{ |
|
351
|
8 |
|
return $this->innerCollection->has(...$callbacks); |
|
352
|
|
|
} |
|
353
|
|
|
|
|
354
|
3 |
|
public function head($default = null): mixed |
|
355
|
|
|
{ |
|
356
|
3 |
|
return $this->innerCollection->head($default); |
|
357
|
|
|
} |
|
358
|
|
|
|
|
359
|
2 |
|
public function ifThenElse(callable $condition, callable $then, ?callable $else = null): static |
|
360
|
|
|
{ |
|
361
|
2 |
|
return new static($this->innerCollection->ifThenElse($condition, $then, $else)); |
|
362
|
|
|
} |
|
363
|
|
|
|
|
364
|
3 |
|
public function implode(string $glue = ''): string |
|
365
|
|
|
{ |
|
366
|
3 |
|
return $this->innerCollection->implode($glue); |
|
367
|
|
|
} |
|
368
|
|
|
|
|
369
|
2 |
|
public function init(): static |
|
370
|
|
|
{ |
|
371
|
2 |
|
return new static($this->innerCollection->init()); |
|
372
|
|
|
} |
|
373
|
|
|
|
|
374
|
2 |
|
public function inits(): static |
|
375
|
|
|
{ |
|
376
|
2 |
|
return new static($this->innerCollection->inits()); |
|
377
|
|
|
} |
|
378
|
|
|
|
|
379
|
2 |
|
public function intersect(mixed ...$values): static |
|
380
|
|
|
{ |
|
381
|
2 |
|
return new static($this->innerCollection->intersect(...$values)); |
|
382
|
|
|
} |
|
383
|
|
|
|
|
384
|
3 |
|
public function intersectKeys(mixed ...$keys): static |
|
385
|
|
|
{ |
|
386
|
3 |
|
return new static($this->innerCollection->intersectKeys(...$keys)); |
|
387
|
|
|
} |
|
388
|
|
|
|
|
389
|
5 |
|
public function intersperse(mixed $element, int $every = 1, int $startAt = 0): static |
|
390
|
|
|
{ |
|
391
|
5 |
|
return new static($this->innerCollection->intersperse($element, $every, $startAt)); |
|
392
|
|
|
} |
|
393
|
|
|
|
|
394
|
7 |
|
public function isEmpty(): bool |
|
395
|
|
|
{ |
|
396
|
7 |
|
return $this->innerCollection->isEmpty(); |
|
397
|
|
|
} |
|
398
|
|
|
|
|
399
|
7 |
|
public function isNotEmpty(): bool |
|
400
|
|
|
{ |
|
401
|
7 |
|
return $this->innerCollection->isNotEmpty(); |
|
402
|
|
|
} |
|
403
|
|
|
|
|
404
|
3 |
|
public function key(int $index = 0): mixed |
|
405
|
|
|
{ |
|
406
|
3 |
|
return $this->innerCollection->key($index); |
|
407
|
|
|
} |
|
408
|
|
|
|
|
409
|
1 |
|
public function keys(): static |
|
410
|
|
|
{ |
|
411
|
1 |
|
return new static($this->innerCollection->keys()); |
|
412
|
|
|
} |
|
413
|
|
|
|
|
414
|
7 |
|
public function last($default = null): mixed |
|
415
|
|
|
{ |
|
416
|
7 |
|
return $this->innerCollection->last($default); |
|
417
|
|
|
} |
|
418
|
|
|
|
|
419
|
5 |
|
public function limit(int $count = -1, int $offset = 0): static |
|
420
|
|
|
{ |
|
421
|
5 |
|
return new static($this->innerCollection->limit($count, $offset)); |
|
422
|
|
|
} |
|
423
|
|
|
|
|
424
|
1 |
|
public function lines(): static |
|
425
|
|
|
{ |
|
426
|
1 |
|
return new static($this->innerCollection->lines()); |
|
427
|
|
|
} |
|
428
|
|
|
|
|
429
|
2 |
|
public function map(callable $callback): static |
|
430
|
|
|
{ |
|
431
|
2 |
|
return new static($this->innerCollection->map($callback)); |
|
432
|
|
|
} |
|
433
|
|
|
|
|
434
|
2 |
|
public function mapN(callable ...$callbacks): static |
|
435
|
|
|
{ |
|
436
|
2 |
|
return new static($this->innerCollection->mapN(...$callbacks)); |
|
437
|
|
|
} |
|
438
|
|
|
|
|
439
|
3 |
|
public function match(callable $callback, ?callable $matcher = null): bool |
|
440
|
|
|
{ |
|
441
|
3 |
|
return $this->innerCollection->match($callback, $matcher); |
|
442
|
|
|
} |
|
443
|
|
|
|
|
444
|
1 |
|
public function matching(Criteria $criteria): static |
|
445
|
|
|
{ |
|
446
|
1 |
|
return new static($this->innerCollection->matching($criteria)); |
|
447
|
|
|
} |
|
448
|
|
|
|
|
449
|
4 |
|
public function max($default = null): mixed |
|
450
|
|
|
{ |
|
451
|
4 |
|
return $this->innerCollection->max($default); |
|
452
|
|
|
} |
|
453
|
|
|
|
|
454
|
1 |
|
public function merge(iterable ...$sources): static |
|
455
|
|
|
{ |
|
456
|
1 |
|
return new static($this->innerCollection->merge(...$sources)); |
|
457
|
|
|
} |
|
458
|
|
|
|
|
459
|
4 |
|
public function min($default = null): mixed |
|
460
|
|
|
{ |
|
461
|
4 |
|
return $this->innerCollection->min($default); |
|
462
|
|
|
} |
|
463
|
|
|
|
|
464
|
3 |
|
public function normalize(): static |
|
465
|
|
|
{ |
|
466
|
3 |
|
return new static($this->innerCollection->normalize()); |
|
467
|
|
|
} |
|
468
|
|
|
|
|
469
|
2 |
|
public function nth(int $step, int $offset = 0): static |
|
470
|
|
|
{ |
|
471
|
2 |
|
return new static($this->innerCollection->nth($step, $offset)); |
|
472
|
|
|
} |
|
473
|
|
|
|
|
474
|
4 |
|
public function nullsy(): bool |
|
475
|
|
|
{ |
|
476
|
4 |
|
return $this->innerCollection->nullsy(); |
|
477
|
|
|
} |
|
478
|
|
|
|
|
479
|
1 |
|
public function pack(): static |
|
480
|
|
|
{ |
|
481
|
1 |
|
return new static($this->innerCollection->pack()); |
|
482
|
|
|
} |
|
483
|
|
|
|
|
484
|
1 |
|
public function pad(int $size, mixed $value): static |
|
485
|
|
|
{ |
|
486
|
1 |
|
return new static($this->innerCollection->pad($size, $value)); |
|
487
|
|
|
} |
|
488
|
|
|
|
|
489
|
3 |
|
public function pair(): static |
|
490
|
|
|
{ |
|
491
|
3 |
|
return new static($this->innerCollection->pair()); |
|
492
|
|
|
} |
|
493
|
|
|
|
|
494
|
1 |
|
public function partition(callable ...$callbacks): static |
|
495
|
|
|
{ |
|
496
|
1 |
|
return new static($this->innerCollection->partition(...$callbacks)); |
|
497
|
|
|
} |
|
498
|
|
|
|
|
499
|
1 |
|
public function permutate(): static |
|
500
|
|
|
{ |
|
501
|
1 |
|
return new static($this->innerCollection->permutate()); |
|
502
|
|
|
} |
|
503
|
|
|
|
|
504
|
1 |
|
public function pipe(callable ...$callbacks): static |
|
505
|
|
|
{ |
|
506
|
1 |
|
return new static($this->innerCollection->pipe(...$callbacks)); |
|
507
|
|
|
} |
|
508
|
|
|
|
|
509
|
6 |
|
public function pluck(mixed $pluck, mixed $default = null): static |
|
510
|
|
|
{ |
|
511
|
6 |
|
return new static($this->innerCollection->pluck($pluck, $default)); |
|
512
|
|
|
} |
|
513
|
|
|
|
|
514
|
1 |
|
public function prepend(mixed ...$items): static |
|
515
|
|
|
{ |
|
516
|
1 |
|
return new static($this->innerCollection->prepend(...$items)); |
|
517
|
|
|
} |
|
518
|
|
|
|
|
519
|
2 |
|
public function product(iterable ...$iterables): static |
|
520
|
|
|
{ |
|
521
|
2 |
|
return new static($this->innerCollection->product(...$iterables)); |
|
522
|
|
|
} |
|
523
|
|
|
|
|
524
|
1 |
|
public function random(int $size = 1, ?int $seed = null): static |
|
525
|
|
|
{ |
|
526
|
1 |
|
return new static($this->innerCollection->random($size, $seed)); |
|
527
|
|
|
} |
|
528
|
|
|
|
|
529
|
1 |
|
public static function range(float $start = 0.0, float $end = INF, float $step = 1.0): CollectionInterface |
|
530
|
|
|
{ |
|
531
|
1 |
|
return new static(Collection::range($start, $end, $step)); |
|
532
|
|
|
} |
|
533
|
|
|
|
|
534
|
3 |
|
public function reduce(callable $callback, mixed $initial = null): mixed |
|
535
|
|
|
{ |
|
536
|
3 |
|
return $this->innerCollection->reduce($callback, $initial); |
|
537
|
|
|
} |
|
538
|
|
|
|
|
539
|
1 |
|
public function reduction(callable $callback, mixed $initial = null): static |
|
540
|
|
|
{ |
|
541
|
1 |
|
return new static($this->innerCollection->reduction($callback, $initial)); |
|
542
|
|
|
} |
|
543
|
|
|
|
|
544
|
4 |
|
public function reject(callable ...$callbacks): static |
|
545
|
|
|
{ |
|
546
|
4 |
|
return new static($this->innerCollection->reject(...$callbacks)); |
|
547
|
|
|
} |
|
548
|
|
|
|
|
549
|
2 |
|
public function reverse(): static |
|
550
|
|
|
{ |
|
551
|
2 |
|
return new static($this->innerCollection->reverse()); |
|
552
|
|
|
} |
|
553
|
|
|
|
|
554
|
|
|
public function rsample(float $probability): static |
|
555
|
|
|
{ |
|
556
|
|
|
return new static($this->innerCollection->rsample($probability)); |
|
557
|
|
|
} |
|
558
|
|
|
|
|
559
|
23 |
|
public function same(iterable $other, ?callable $comparatorCallback = null): bool |
|
560
|
|
|
{ |
|
561
|
23 |
|
return $this->innerCollection->same($other, $comparatorCallback); |
|
562
|
|
|
} |
|
563
|
|
|
|
|
564
|
1 |
|
public function scale( |
|
565
|
|
|
float $lowerBound, |
|
566
|
|
|
float $upperBound, |
|
567
|
|
|
float $wantedLowerBound = 0.0, |
|
568
|
|
|
float $wantedUpperBound = 1.0, |
|
569
|
|
|
float $base = 0.0 |
|
570
|
|
|
): static { |
|
571
|
1 |
|
return new static($this->innerCollection->scale($lowerBound, $upperBound, $wantedLowerBound, $wantedUpperBound)); |
|
572
|
|
|
} |
|
573
|
|
|
|
|
574
|
2 |
|
public function scanLeft(callable $callback, mixed $initial): static |
|
575
|
|
|
{ |
|
576
|
2 |
|
return new static($this->innerCollection->scanLeft($callback, $initial)); |
|
577
|
|
|
} |
|
578
|
|
|
|
|
579
|
3 |
|
public function scanLeft1(callable $callback): static |
|
580
|
|
|
{ |
|
581
|
3 |
|
return new static($this->innerCollection->scanLeft1($callback)); |
|
582
|
|
|
} |
|
583
|
|
|
|
|
584
|
2 |
|
public function scanRight(callable $callback, mixed $initial): static |
|
585
|
|
|
{ |
|
586
|
2 |
|
return new static($this->innerCollection->scanRight($callback, $initial)); |
|
587
|
|
|
} |
|
588
|
|
|
|
|
589
|
2 |
|
public function scanRight1(callable $callback): static |
|
590
|
|
|
{ |
|
591
|
2 |
|
return new static($this->innerCollection->scanRight1($callback)); |
|
592
|
|
|
} |
|
593
|
|
|
|
|
594
|
1 |
|
public function shuffle(?int $seed = null): static |
|
595
|
|
|
{ |
|
596
|
1 |
|
return new static($this->innerCollection->shuffle($seed)); |
|
597
|
|
|
} |
|
598
|
|
|
|
|
599
|
4 |
|
public function since(callable ...$callbacks): static |
|
600
|
|
|
{ |
|
601
|
4 |
|
return new static($this->innerCollection->since(...$callbacks)); |
|
602
|
|
|
} |
|
603
|
|
|
|
|
604
|
3 |
|
public function slice(int $offset, int $length = -1): static |
|
605
|
|
|
{ |
|
606
|
3 |
|
return new static($this->innerCollection->slice($offset, $length)); |
|
607
|
|
|
} |
|
608
|
|
|
|
|
609
|
5 |
|
public function sort(int $type = Operation\Sortable::BY_VALUES, null|callable|Closure $callback = null): static |
|
610
|
|
|
{ |
|
611
|
5 |
|
return new static($this->innerCollection->sort($type, $callback)); |
|
612
|
|
|
} |
|
613
|
|
|
|
|
614
|
1 |
|
public function span(callable ...$callbacks): static |
|
615
|
|
|
{ |
|
616
|
1 |
|
return new static($this->innerCollection->span(...$callbacks)); |
|
617
|
|
|
} |
|
618
|
|
|
|
|
619
|
3 |
|
public function split(int $type = Operation\Splitable::BEFORE, callable ...$callbacks): static |
|
620
|
|
|
{ |
|
621
|
3 |
|
return new static($this->innerCollection->split($type, ...$callbacks)); |
|
622
|
|
|
} |
|
623
|
|
|
|
|
624
|
1 |
|
public function squash(): static |
|
625
|
|
|
{ |
|
626
|
1 |
|
return new static($this->innerCollection->squash()); |
|
627
|
|
|
} |
|
628
|
|
|
|
|
629
|
1 |
|
public function strict(?callable $callback = null): static |
|
630
|
|
|
{ |
|
631
|
1 |
|
return new static($this->innerCollection->strict($callback)); |
|
632
|
|
|
} |
|
633
|
|
|
|
|
634
|
1 |
|
public function tail(): static |
|
635
|
|
|
{ |
|
636
|
1 |
|
return new static($this->innerCollection->tail()); |
|
637
|
|
|
} |
|
638
|
|
|
|
|
639
|
2 |
|
public function tails(): static |
|
640
|
|
|
{ |
|
641
|
2 |
|
return new static($this->innerCollection->tails()); |
|
642
|
|
|
} |
|
643
|
|
|
|
|
644
|
3 |
|
public function takeWhile(callable ...$callbacks): static |
|
645
|
|
|
{ |
|
646
|
3 |
|
return new static($this->innerCollection->takeWhile(...$callbacks)); |
|
647
|
|
|
} |
|
648
|
|
|
|
|
649
|
1 |
|
public function tap(callable ...$callbacks): static |
|
650
|
|
|
{ |
|
651
|
1 |
|
return new static($this->innerCollection->tap(...$callbacks)); |
|
652
|
|
|
} |
|
653
|
|
|
|
|
654
|
1 |
|
public static function times(int $number = 0, ?callable $callback = null): static |
|
655
|
|
|
{ |
|
656
|
1 |
|
return new static(Collection::times($number, $callback)); |
|
657
|
|
|
} |
|
658
|
|
|
|
|
659
|
1 |
|
public function transpose(): static |
|
660
|
|
|
{ |
|
661
|
1 |
|
return new static($this->innerCollection->transpose()); |
|
662
|
|
|
} |
|
663
|
|
|
|
|
664
|
4 |
|
public function truthy(): bool |
|
665
|
|
|
{ |
|
666
|
4 |
|
return $this->innerCollection->truthy(); |
|
667
|
|
|
} |
|
668
|
|
|
|
|
669
|
1 |
|
public static function unfold(callable $callback, iterable $parameters = []): static |
|
670
|
|
|
{ |
|
671
|
1 |
|
return new static(Collection::unfold($callback, $parameters)); |
|
672
|
|
|
} |
|
673
|
|
|
|
|
674
|
1 |
|
public function unlines(): string |
|
675
|
|
|
{ |
|
676
|
1 |
|
return $this->innerCollection->unlines(); |
|
677
|
|
|
} |
|
678
|
|
|
|
|
679
|
1 |
|
public function unpack(): static |
|
680
|
|
|
{ |
|
681
|
1 |
|
return new static($this->innerCollection->unpack()); |
|
682
|
|
|
} |
|
683
|
|
|
|
|
684
|
1 |
|
public function unpair(): static |
|
685
|
|
|
{ |
|
686
|
1 |
|
return new static($this->innerCollection->unpair()); |
|
687
|
|
|
} |
|
688
|
|
|
|
|
689
|
2 |
|
public function until(callable ...$callbacks): static |
|
690
|
|
|
{ |
|
691
|
2 |
|
return new static($this->innerCollection->until(...$callbacks)); |
|
692
|
|
|
} |
|
693
|
|
|
|
|
694
|
1 |
|
public function unwindow(): static |
|
695
|
|
|
{ |
|
696
|
1 |
|
return new static($this->innerCollection->unwindow()); |
|
697
|
|
|
} |
|
698
|
|
|
|
|
699
|
1 |
|
public function unwords(): string |
|
700
|
|
|
{ |
|
701
|
1 |
|
return $this->innerCollection->unwords(); |
|
702
|
|
|
} |
|
703
|
|
|
|
|
704
|
3 |
|
public function unwrap(): static |
|
705
|
|
|
{ |
|
706
|
3 |
|
return new static($this->innerCollection->unwrap()); |
|
707
|
|
|
} |
|
708
|
|
|
|
|
709
|
1 |
|
public function unzip(): static |
|
710
|
|
|
{ |
|
711
|
1 |
|
return new static($this->innerCollection->unzip()); |
|
712
|
|
|
} |
|
713
|
|
|
|
|
714
|
2 |
|
public function when(callable $predicate, callable $whenTrue, ?callable $whenFalse = null): static |
|
715
|
|
|
{ |
|
716
|
2 |
|
return new static($this->innerCollection->when($predicate, $whenTrue, $whenFalse)); |
|
717
|
|
|
} |
|
718
|
|
|
|
|
719
|
4 |
|
public function window(int $size): static |
|
720
|
|
|
{ |
|
721
|
4 |
|
return new static($this->innerCollection->window($size)); |
|
722
|
|
|
} |
|
723
|
|
|
|
|
724
|
1 |
|
public function words(): static |
|
725
|
|
|
{ |
|
726
|
1 |
|
return new static($this->innerCollection->words()); |
|
727
|
|
|
} |
|
728
|
|
|
|
|
729
|
2 |
|
public function wrap(): static |
|
730
|
|
|
{ |
|
731
|
2 |
|
return new static($this->innerCollection->wrap()); |
|
732
|
|
|
} |
|
733
|
|
|
|
|
734
|
2 |
|
public function zip(iterable ...$iterables): static |
|
735
|
|
|
{ |
|
736
|
2 |
|
return new static($this->innerCollection->zip(...$iterables)); |
|
737
|
|
|
} |
|
738
|
|
|
} |
|
739
|
|
|
|