class RecursiveCachingIterator extends CachingIterator implements RecursiveIterator (View source)

...

Constants

CALL_TOSTRING

String conversion flag (mutually exclusive): Uses the current element for the iterator's string conversion.

This converts the current element to a string only once, regardless of whether it is needed or not.

TOSTRING_USE_KEY

String conversion flag (mutually exclusive). Uses the current key for the iterator's string conversion.

TOSTRING_USE_CURRENT

String conversion flag (mutually exclusive). Uses the current element for the iterator's string conversion.

This converts the current element to a string only when (and every time) it is needed.

TOSTRING_USE_INNER

String conversion flag (mutually exclusive). Forwards the string conversion to the inner iterator.

This converts the inner iterator to a string only once, regardless of whether it is needed or not.

CATCH_GET_CHILD

Ignore exceptions thrown in accessing children. Only used with {RecursiveCachingIterator}.

FULL_CACHE

Cache all read data. This is needed to use {CachingIterator and ArrayAccess and Countable methods.

Methods

__construct(Traversable $iterator, int $flags = CachingIterator::CALL_TOSTRING)

Constructs a new RecursiveCachingIterator.

Iterator|null
getInnerIterator()

Returns the inner iterator

void
rewind()

Rewind the iterator

bool
valid()

Check whether the current element is valid

mixed
key()

Return the key for the current element

mixed
current()

Return the current element

void
next()

Move the iterator forward

bool
hasNext()

Check whether the inner iterator has a valid next element

string
__toString()

Return the string representation of the current iteration based on the flag being used.

int
getFlags()

Get flags used

void
setFlags(int $flags)

The setFlags purpose

mixed
offsetGet(string $key)

Internal cache array index to retrieve.

void
offsetSet(string $key, TValue $value)

Set an element on the internal cache array.

void
offsetUnset(string $key)

Remove an element from the internal cache array.

bool
offsetExists(string $key)

Return whether an element at the index exists on the internal cache array.

array
getCache()

Retrieve the contents of the cache

int
count()

The number of elements in the iterator

bool
hasChildren()

Check whether the current element of the inner iterator has children

getChildren()

Return the inner iterator's children as a RecursiveCachingIterator

Details

__construct(Traversable $iterator, int $flags = CachingIterator::CALL_TOSTRING)

Constructs a new RecursiveCachingIterator.

Parameters

Traversable $iterator
int $flags

[optional] A bitmask of flags. See CachingIterator class constants for details.

Iterator|null getInnerIterator()

Returns 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()

Return the key for the current element

Return Value

mixed

TKey on success, or null on failure.

mixed current()

Return the current element

Return Value

mixed

Can return any type.

void next()

Move the iterator forward

Return Value

void

Any returned value is ignored.

bool hasNext()

Check whether the inner iterator has a valid next element

Return Value

bool

true on success or false on failure.

string __toString()

Return the string representation of the current iteration based on the flag being used.

Return Value

string

Returns string representation of the object that implements this interface (and/or "__toString" magic method).

int getFlags()

Get flags used

Return Value

int

Bitmask of the flags

void setFlags(int $flags)

The setFlags purpose

Parameters

int $flags

Bitmask of the flags to set.

Return Value

void

mixed offsetGet(string $key)

Internal cache array index to retrieve.

Parameters

string $key

The index of the element to retrieve.

Return Value

mixed

Can return all value types.

Exceptions

BadMethodCallException

void offsetSet(string $key, TValue $value)

Set an element on the internal cache array.

Parameters

string $key

The index of the element to be set.

TValue $value

The value to set.

Return Value

void

Exceptions

BadMethodCallException

void offsetUnset(string $key)

Remove an element from the internal cache array.

Parameters

string $key

The index of the element to be unset.

Return Value

void

Exceptions

BadMethodCallException

bool offsetExists(string $key)

Return whether an element at the index exists on the internal cache array.

Parameters

string $key

The index being checked.

Return Value

bool

true on success or false on failure.

The return value will be casted to boolean if non-boolean was returned.

Exceptions

BadMethodCallException

array getCache()

Retrieve the contents of the cache

Return Value

array

An array containing the cache items.

Exceptions

BadMethodCallException

int count()

Since: 5.2.2

The number of elements in the iterator

Return Value

int

The custom count as an integer.

The return value is cast to an integer.

Exceptions

BadMethodCallException

bool hasChildren()

Check whether the current element of the inner iterator has children

Return Value

bool

true if the current entry can be iterated over, otherwise returns false.

RecursiveIterator|null getChildren()

Return the inner iterator's children as a RecursiveCachingIterator

Return Value

RecursiveIterator|null

An iterator for the current entry.