abstract class FilterIterator extends IteratorIterator (View source)

This abstract iterator filters out unwanted values. This class should be extended to implement custom iterator filters. The FilterIterator::accept must be implemented in the subclass.

Methods

__construct(Traversable $iterator)

Construct a filterIterator

Iterator|null
getInnerIterator()

Get the inner iterator

void
rewind()

Rewind the iterator

bool
valid()

Check whether the current element is valid

mixed
key()

Get the current key

mixed
current()

Get the current element value

void
next()

Move the iterator forward

bool
accept()

Check whether the current element of the iterator is acceptable

Details

__construct(Traversable $iterator)

Construct a filterIterator

Parameters

Traversable $iterator

Iterator|null getInnerIterator()

Get the inner iterator

Return Value

Iterator|null

The inner iterator for the current entry.

void rewind()

Rewind the iterator

Return Value

void

Any returned value is ignored.

bool valid()

Check whether the current element is valid

Return Value

bool

The return value will be casted to boolean and then evaluated. Returns true on success or false on failure.

mixed key()

Get the current key

Return Value

mixed

TKey on success, or null on failure.

mixed current()

Get the current element value

Return Value

mixed

Can return any type.

void next()

Move the iterator forward

Return Value

void

Any returned value is ignored.

abstract bool accept()

Check whether the current element of the iterator is acceptable

Return Value

bool

true if the current element is acceptable, otherwise false.