Iterables
final class Iterables
Utilities for iterables.
Methods
Tests for the presence of value.
Tests for the presence of key.
No description
No description
Tests whether at least one element in the iterable passes the test implemented by the provided function.
Tests whether all elements in the iterable pass the test implemented by the provided function.
Returns a generator that yields only elements matching the given $predicate. Maintains original keys.
Returns a generator that transforms values by calling $transformer. Maintains original keys.
Returns a generator that transforms keys and values by calling $transformer. If it returns null, the element is skipped.
No description
No description
Details
at line 25
static bool
contains(iterable $iterable, mixed $value)
Tests for the presence of value.
at line 40
static bool
containsKey(iterable $iterable, mixed $key)
Tests for the presence of key.
at line 61
static mixed
first(iterable $iterable, callable|null $predicate = null, callable|null $else = null)
No description
at line 82
static mixed
firstKey(iterable $iterable, callable|null $predicate = null, callable|null $else = null)
No description
at line 100
static bool
some(iterable $iterable, callable $predicate)
Tests whether at least one element in the iterable passes the test implemented by the provided function.
at line 118
static bool
every(iterable $iterable, callable $predicate)
Tests whether all elements in the iterable pass the test implemented by the provided function.
at line 137
static Generator
filter(iterable $iterable, callable $predicate)
Returns a generator that yields only elements matching the given $predicate. Maintains original keys.
at line 156
static Generator
map(iterable $iterable, callable $transformer)
Returns a generator that transforms values by calling $transformer. Maintains original keys.
at line 174
static Generator
mapWithKeys(iterable $iterable, callable $transformer)
Returns a generator that transforms keys and values by calling $transformer. If it returns null, the element is skipped.
at line 193
static IteratorAggregate
repeatable(callable $factory)
No description
at line 196
__construct(Closure $factory)
No description
at line 203
Iterator
getIterator()
No description
Traits
Prevents instantiation.