final class Iterables

Utilities for iterables.

Methods

static bool
contains(iterable $iterable, mixed $value)

Tests for the presence of value.

static bool
containsKey(iterable $iterable, mixed $key)

Tests for the presence of key.

static mixed
first(iterable $iterable, callable|null $predicate = null, callable|null $else = null)

No description

static mixed
firstKey(iterable $iterable, callable|null $predicate = null, callable|null $else = null)

No description

static bool
some(iterable $iterable, callable $predicate)

Tests whether at least one element in the iterable passes the test implemented by the provided function.

static bool
every(iterable $iterable, callable $predicate)

Tests whether all elements in the iterable pass the test implemented by the provided function.

static Generator
filter(iterable $iterable, callable $predicate)

Returns a generator that yields only elements matching the given $predicate. Maintains original keys.

static Generator
map(iterable $iterable, callable $transformer)

Returns a generator that transforms values by calling $transformer. Maintains original keys.

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.

repeatable(callable $factory)

No description

__construct(Closure $factory)

No description

getIterator()

No description

Details

at line 25
static bool contains(iterable $iterable, mixed $value)

Tests for the presence of value.

Parameters

iterable $iterable
mixed $value

Return Value

bool

at line 40
static bool containsKey(iterable $iterable, mixed $key)

Tests for the presence of key.

Parameters

iterable $iterable
mixed $key

Return Value

bool

at line 61
static mixed first(iterable $iterable, callable|null $predicate = null, callable|null $else = null)

No description

Parameters

iterable $iterable
callable|null $predicate
callable|null $else

Return Value

mixed

at line 82
static mixed firstKey(iterable $iterable, callable|null $predicate = null, callable|null $else = null)

No description

Parameters

iterable $iterable
callable|null $predicate
callable|null $else

Return Value

mixed

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.

Parameters

iterable $iterable
callable $predicate

Return Value

bool

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.

Parameters

iterable $iterable
callable $predicate

Return Value

bool

at line 137
static Generator filter(iterable $iterable, callable $predicate)

Returns a generator that yields only elements matching the given $predicate. Maintains original keys.

Parameters

iterable $iterable
callable $predicate

Return Value

Generator

at line 156
static Generator map(iterable $iterable, callable $transformer)

Returns a generator that transforms values by calling $transformer. Maintains original keys.

Parameters

iterable $iterable
callable $transformer

Return Value

Generator

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.

Parameters

iterable $iterable
callable $transformer

Return Value

Generator

at line 193
static IteratorAggregate repeatable(callable $factory)

No description

Parameters

callable $factory

Return Value

IteratorAggregate

at line 196
__construct(Closure $factory)

No description

Parameters

Closure $factory

at line 203
Iterator getIterator()

No description

Return Value

Iterator

Traits

Prevents instantiation.