class RecursiveTreeIterator extends RecursiveIteratorIterator (View source)

Allows iterating over a RecursiveIterator to generate an ASCII graphic tree.

Constants

LEAVES_ONLY

The default. Lists only leaves in iteration.

SELF_FIRST

Lists leaves and parents in iteration with parents coming first.

CHILD_FIRST

Lists leaves and parents in iteration with leaves coming first.

CATCH_GET_CHILD

Special flag: Ignore exceptions thrown in accessing children.

BYPASS_CURRENT

BYPASS_KEY

PREFIX_LEFT

PREFIX_MID_HAS_NEXT

PREFIX_MID_LAST

PREFIX_END_HAS_NEXT

PREFIX_END_LAST

PREFIX_RIGHT

Methods

__construct(Traversable $iterator, int $flags = self::BYPASS_KEY, int $cachingIteratorFlags = CachingIterator::CATCH_GET_CHILD, int $mode = RecursiveIteratorIterator::SELF_FIRST)

Construct a RecursiveTreeIterator

void
rewind()

Rewind iterator

bool
valid()

Check validity

mixed
key()

Get the key of the current element

mixed
current()

Get current element

void
next()

Move to next element

int
getDepth()

Get the current depth of the recursive iteration

getSubIterator(int $level)

The current active sub iterator

Iterator|null
getInnerIterator()

Get inner iterator

void
beginIteration()

Begin iteration

void
endIteration()

End iteration

bool
callHasChildren()

Has children

callGetChildren()

Get children

void
beginChildren()

Begin children

void
endChildren()

End children

void
nextElement()

Next element

void
setMaxDepth(int $maxDepth = -1)

Set max depth

int|false
getMaxDepth()

Get max depth

string
getPrefix()

Get the prefix

void
setPostfix(string $postfix)

No description

void
setPrefixPart(int $part, string $value)

Set a part of the prefix

string
getEntry()

Get current entry

string
getPostfix()

Get the postfix

Details

__construct(Traversable $iterator, int $flags = self::BYPASS_KEY, int $cachingIteratorFlags = CachingIterator::CATCH_GET_CHILD, int $mode = RecursiveIteratorIterator::SELF_FIRST)

Construct a RecursiveTreeIterator

Parameters

Traversable $iterator
int $flags

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

int $cachingIteratorFlags

[optional] Flags to affect the behavior of the {\RecursiveCachingIterator} used internally.

int $mode

[optional] The operation mode. See class constants for details.

void rewind()

Rewind iterator

Return Value

void

Any returned value is ignored.

bool valid()

Check validity

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 key of the current element

Return Value

mixed

TKey on success, or null on failure.

mixed current()

Get current element

Return Value

mixed

Can return any type.

void next()

Move to next element

Return Value

void

Any returned value is ignored.

int getDepth()

Get the current depth of the recursive iteration

Return Value

int

The current depth of the recursive iteration.

RecursiveIterator|null getSubIterator(int $level)

The current active sub iterator

Parameters

int $level [optional]

Return Value

RecursiveIterator|null

The current active sub iterator.

Iterator|null getInnerIterator()

Get inner iterator

Return Value

Iterator|null

The inner iterator for the current entry.

void beginIteration()

Begin iteration

Return Value

void

void endIteration()

End iteration

Return Value

void

bool callHasChildren()

Has children

Return Value

bool

true if the element has children, otherwise false

RecursiveIterator|null callGetChildren()

Get children

Return Value

RecursiveIterator|null

A RecursiveIterator.

void beginChildren()

Begin children

Return Value

void

void endChildren()

End children

Return Value

void

void nextElement()

Next element

Return Value

void

void setMaxDepth(int $maxDepth = -1)

Set max depth

Parameters

int $maxDepth

[optional]

The maximum allowed depth. Default -1 is used for any depth.

Return Value

void

int|false getMaxDepth()

Get max depth

Return Value

int|false

The maximum accepted depth, or false if any depth is allowed.

string getPrefix()

Get the prefix

Return Value

string

the string to place in front of current element

void setPostfix(string $postfix)

No description

Parameters

string $postfix

Return Value

void

void setPrefixPart(int $part, string $value)

Set a part of the prefix

Parameters

int $part

One of the RecursiveTreeIterator::PREFIX_* constants.

string $value

The value to assign to the part of the prefix specified in part.

Return Value

void

string getEntry()

Get current entry

Return Value

string

the part of the tree built for the current element.

string getPostfix()

Get the postfix

Return Value

string

to place after the current element.