Fr3nch13/CakePHP Utilities

TreePrinter extends RecursiveIteratorIterator
in package
implements CollectionInterface uses CollectionTrait

Iterator for flattening elements in a tree structure while adding some visual markers for their relative position in the tree

Table of Contents

Interfaces

CollectionInterface
Describes the methods a Collection should implement. A collection is an immutable list of elements exposing a number of traversing and extracting method for generating other collections.

Properties

$_current  : mixed
Cached value for the current iteration element
$_key  : callable
A callable to generate the iteration key
$_spacer  : string
The string to use for prefixing the values according to their depth in the tree.
$_value  : callable
A callable to extract the display value

Methods

__construct()  : mixed
Constructor
append()  : CollectionInterface
appendItem()  : CollectionInterface
avg()  : mixed
buffered()  : CollectionInterface
cartesianProduct()  : CollectionInterface
{@inheritDoc}
chunk()  : CollectionInterface
chunkWithKeys()  : CollectionInterface
combine()  : CollectionInterface
compile()  : CollectionInterface
contains()  : bool
count()  : int
countBy()  : CollectionInterface
countKeys()  : int
current()  : string
Returns the current iteration value
each()  : mixed
every()  : bool
extract()  : CollectionInterface
filter()  : CollectionInterface
first()  : mixed
firstMatch()  : mixed
groupBy()  : CollectionInterface
indexBy()  : CollectionInterface
insert()  : CollectionInterface
isEmpty()  : bool
jsonSerialize()  : array<string|int, mixed>
key()  : mixed
Returns the current iteration key
last()  : mixed
lazy()  : CollectionInterface
listNested()  : CollectionInterface
map()  : CollectionInterface
match()  : CollectionInterface
max()  : mixed
median()  : mixed
min()  : mixed
nest()  : CollectionInterface
next()  : void
Advances the cursor one position
prepend()  : CollectionInterface
prependItem()  : CollectionInterface
reduce()  : mixed
reject()  : CollectionInterface
sample()  : CollectionInterface
shuffle()  : CollectionInterface
skip()  : CollectionInterface
some()  : bool
sortBy()  : CollectionInterface
stopWhen()  : CollectionInterface
sumOf()  : mixed
take()  : CollectionInterface
takeLast()  : CollectionInterface
through()  : CollectionInterface
toArray()  : array<string|int, mixed>
toList()  : array<string|int, mixed>
transpose()  : CollectionInterface
{@inheritDoc}
unfold()  : CollectionInterface
unwrap()  : Traversable
zip()  : CollectionInterface
zipWith()  : CollectionInterface
_fetchCurrent()  : mixed
Returns the current iteration element and caches its value
newCollection()  : CollectionInterface
Returns a new collection.
optimizeUnwrap()  : iterable<string|int, mixed>
Unwraps this iterator and returns the simplest traversable that can be used for getting the data out

Properties

$_current

Cached value for the current iteration element

protected mixed $_current

$_key

A callable to generate the iteration key

protected callable $_key

$_spacer

The string to use for prefixing the values according to their depth in the tree.

protected string $_spacer

$_value

A callable to extract the display value

protected callable $_value

Methods

__construct()

Constructor

public __construct(RecursiveIterator $items, callable|string $valuePath, callable|string $keyPath, string $spacer[, int $mode = RecursiveIteratorIterator::SELF_FIRST ]) : mixed
Parameters
$items : RecursiveIterator

The iterator to flatten.

$valuePath : callable|string

The property to extract or a callable to return the display value.

$keyPath : callable|string

The property to use as iteration key or a callable returning the key value.

$spacer : string

The string to use for prefixing the values according to their depth in the tree.

$mode : int = RecursiveIteratorIterator::SELF_FIRST

Iterator mode.

avg()

public avg([mixed $path = null ]) : mixed
Parameters
$path : mixed = null
Tags
inheritDoc

cartesianProduct()

{@inheritDoc}

public cartesianProduct([callable|null $operation = null ][, callable|null $filter = null ]) : CollectionInterface
Parameters
$operation : callable|null = null

A callable that allows you to customize the product result.

$filter : callable|null = null

A filtering callback that must return true for a result to be part of the final results.

Tags
throws
LogicException
Return values
CollectionInterface

contains()

public contains(mixed $value) : bool
Parameters
$value : mixed
Tags
inheritDoc
Return values
bool

countKeys()

public countKeys() : int
Tags
inheritDoc
Return values
int

current()

Returns the current iteration value

public current() : string
Return values
string

each()

public each(callable $callback) : mixed
Parameters
$callback : callable
Tags
inheritDoc

every()

public every(callable $callback) : bool
Parameters
$callback : callable
Tags
inheritDoc
Return values
bool

firstMatch()

public firstMatch(array<string|int, mixed> $conditions) : mixed
Parameters
$conditions : array<string|int, mixed>
Tags
inheritDoc

isEmpty()

public isEmpty() : bool
Tags
inheritDoc
Return values
bool

jsonSerialize()

public jsonSerialize() : array<string|int, mixed>
Tags
inheritDoc
Return values
array<string|int, mixed>

key()

Returns the current iteration key

public key() : mixed
Attributes
#[ReturnTypeWillChange]

max()

public max(mixed $path[, int $sort = SORT_NUMERIC ]) : mixed
Parameters
$path : mixed
$sort : int = SORT_NUMERIC
Tags
inheritDoc

median()

public median([mixed $path = null ]) : mixed
Parameters
$path : mixed = null
Tags
inheritDoc

min()

public min(mixed $path[, int $sort = SORT_NUMERIC ]) : mixed
Parameters
$path : mixed
$sort : int = SORT_NUMERIC
Tags
inheritDoc

next()

Advances the cursor one position

public next() : void

reduce()

public reduce(callable $callback[, mixed $initial = null ]) : mixed
Parameters
$callback : callable
$initial : mixed = null
Tags
inheritDoc

some()

public some(callable $callback) : bool
Parameters
$callback : callable
Tags
inheritDoc
Return values
bool

sumOf()

public sumOf([mixed $path = null ]) : mixed
Parameters
$path : mixed = null
Tags
inheritDoc

toArray()

public toArray([bool $keepKeys = true ]) : array<string|int, mixed>
Parameters
$keepKeys : bool = true
Tags
inheritDoc
Return values
array<string|int, mixed>

toList()

public toList() : array<string|int, mixed>
Tags
inheritDoc
Return values
array<string|int, mixed>

unwrap()

public unwrap() : Traversable
Tags
inheritDoc
Return values
Traversable

_fetchCurrent()

Returns the current iteration element and caches its value

protected _fetchCurrent() : mixed

newCollection()

Returns a new collection.

protected newCollection(mixed ...$args) : CollectionInterface

Allows classes which use this trait to determine their own type of returned collection interface

Parameters
$args : mixed

Constructor arguments.

Return values
CollectionInterface

optimizeUnwrap()

Unwraps this iterator and returns the simplest traversable that can be used for getting the data out

protected optimizeUnwrap() : iterable<string|int, mixed>
Return values
iterable<string|int, mixed>

        
On this page

Search results