Class TreePrinter
Iterator for flattening elements in a tree structure while adding some visual markers for their relative position in the tree
Property Summary
- 
        $_current protectedmixedCached value for the current iteration element 
- 
        $_key protectedcallableA callable to generate the iteration key 
- 
        $_spacer protectedstringThe string to use for prefixing the values according to their depth in the tree. 
- 
        $_value protectedcallableA callable to extract the display value 
Method Summary
- 
          __construct() publicConstructor 
- 
          _createMatcherFilter() protectedReturns a callable that receives a value and will return whether or not it matches certain condition. 
- 
          _extract() protectedReturns a column from $data that can be extracted by iterating over the column names contained in $path. It will return arrays for elements in represented with {*}
- 
          _fetchCurrent() protectedReturns the current iteration element and caches its value 
- 
          _propertyExtractor() protectedReturns a callable that can be used to extract a property or column from an array or object based on a dot separated path. 
- 
          _simpleExtract() protectedReturns a column from $data that can be extracted by iterating over the column names contained in $path 
- 
          _unwrap() public deprecatedBackwards compatible wrapper for unwrap() 
- 
          append() public{@inheritDoc} 
- 
          buffered() public{@inheritDoc} 
- 
          cartesianProduct() public{@inheritDoc} 
- 
          chunk() public{@inheritDoc} 
- 
          combine() public{@inheritDoc} 
- 
          compile() public{@inheritDoc} 
- 
          contains() public{@inheritDoc} 
- 
          countBy() public{@inheritDoc} 
- 
          current() publicReturns the current iteration value 
- 
          each() public{@inheritDoc} 
- 
          every() public{@inheritDoc} 
- 
          extract() public{@inheritDoc} 
- 
          filter() public{@inheritDoc} 
- 
          first() public{@inheritDoc} 
- 
          firstMatch() public{@inheritDoc} 
- 
          groupBy() public{@inheritDoc} 
- 
          indexBy() public{@inheritDoc} 
- 
          insert() public{@inheritDoc} 
- 
          isEmpty() public{@inheritDoc} 
- 
          jsonSerialize() public{@inheritDoc} 
- 
          key() publicReturns the current iteration key 
- 
          last() public{@inheritDoc} 
- 
          listNested() public{@inheritDoc} 
- 
          map() public{@inheritDoc} 
- 
          match() public{@inheritDoc} 
- 
          max() public{@inheritDoc} 
- 
          min() public{@inheritDoc} 
- 
          nest() public{@inheritDoc} 
- 
          next() publicAdvances the cursor one position 
- 
          reduce() public{@inheritDoc} 
- 
          reject() public{@inheritDoc} 
- 
          sample() public{@inheritDoc} 
- 
          shuffle() public{@inheritDoc} 
- 
          skip() public{@inheritDoc} 
- 
          some() public{@inheritDoc} 
- 
          sortBy() public{@inheritDoc} 
- 
          stopWhen() public{@inheritDoc} 
- 
          sumOf() public{@inheritDoc} 
- 
          take() public{@inheritDoc} 
- 
          through() public{@inheritDoc} 
- 
          toArray() public{@inheritDoc} 
- 
          toList() public{@inheritDoc} 
- 
          transpose() public{@inheritDoc} 
- 
          unfold() public{@inheritDoc} 
- 
          unwrap() public{@inheritDoc} 
- 
          zip() public{@inheritDoc} 
- 
          zipWith() public{@inheritDoc} 
Method Detail
__construct() ¶ public
__construct(RecursiveIterator $items, string|callable $valuePath, string|callable $keyPath, string $spacer, int $mode = RecursiveIteratorIterator::SELF_FIRST)Constructor
Parameters
- 
                RecursiveIterator$items
- The iterator to flatten. 
- 
                string|callable$valuePath
- The property to extract or a callable to return the display value. 
- 
                string|callable$keyPath
- The property to use as iteration key or a callable returning the key value. 
- 
                string$spacer
- The string to use for prefixing the values according to their depth in the tree. 
- 
                int$mode optional
- Iterator mode. 
_createMatcherFilter() ¶ protected
_createMatcherFilter(array $conditions): callableReturns a callable that receives a value and will return whether or not it matches certain condition.
Parameters
- 
                array$conditions
- A key-value list of conditions to match where the key is the property path to get from the current item and the value is the value to be compared the item with. 
Returns
callable_extract() ¶ protected
_extract(array|ArrayAccess $data, array $path): mixedReturns a column from $data that can be extracted
by iterating over the column names contained in $path.
It will return arrays for elements in represented with {*}
Parameters
- 
                array|ArrayAccess$data
- Data. 
- 
                array$path
- Path to extract from. 
Returns
mixed_fetchCurrent() ¶ protected
_fetchCurrent(): mixedReturns the current iteration element and caches its value
Returns
mixed_propertyExtractor() ¶ protected
_propertyExtractor(string|callable $callback): callableReturns a callable that can be used to extract a property or column from an array or object based on a dot separated path.
Parameters
- 
                string|callable$callback
- A dot separated path of column to follow so that the final one can be returned or a callable that will take care of doing that. 
Returns
callable_simpleExtract() ¶ protected
_simpleExtract(array|ArrayAccess $data, array $path): mixedReturns a column from $data that can be extracted by iterating over the column names contained in $path
Parameters
- 
                array|ArrayAccess$data
- Data. 
- 
                array$path
- Path to extract from. 
Returns
mixedbuffered() ¶ public
buffered(): Cake\Collection\Iterator\BufferedIterator{@inheritDoc}
Returns
Cake\Collection\Iterator\BufferedIteratorcartesianProduct() ¶ public
cartesianProduct(callable $operation = null, callable $filter = null): Cake\Collection\CollectionInterface{@inheritDoc}
Parameters
- 
                callable$operation optional
- 
                callable$filter optional
Returns
Cake\Collection\CollectionInterfacecombine() ¶ public
combine(mixed $keyPath, mixed $valuePath, mixed $groupPath = null){@inheritDoc}
Parameters
- 
                $keyPath
- 
                $valuePath
- 
                $groupPath optional
compile() ¶ public
compile(mixed $preserveKeys = true){@inheritDoc}
Parameters
- 
                $preserveKeys optional
filter() ¶ public
filter(callable $c = null): Cake\Collection\Iterator\FilterIterator{@inheritDoc}
Parameters
- 
                callable$c optional
Returns
Cake\Collection\Iterator\FilterIteratorinsert() ¶ public
insert(mixed $path, mixed $values): Cake\Collection\Iterator\InsertIterator{@inheritDoc}
Parameters
- 
                $path
- 
                $values
Returns
Cake\Collection\Iterator\InsertIteratorlistNested() ¶ public
listNested(mixed $dir = 'desc', mixed $nestingKey = 'children'): Cake\Collection\Iterator\TreeIterator{@inheritDoc}
Parameters
- 
                $dir optional
- 
                $nestingKey optional
Returns
Cake\Collection\Iterator\TreeIteratormap() ¶ public
map(callable $c): Cake\Collection\Iterator\ReplaceIterator{@inheritDoc}
Parameters
- 
                callable$c
Returns
Cake\Collection\Iterator\ReplaceIteratormax() ¶ public
max(mixed $callback, mixed $type = SORT_NUMERIC){@inheritDoc}
Parameters
- 
                $callback
- 
                $type optional
min() ¶ public
min(mixed $callback, mixed $type = SORT_NUMERIC){@inheritDoc}
Parameters
- 
                $callback
- 
                $type optional
nest() ¶ public
nest(mixed $idPath, mixed $parentPath, mixed $nestingKey = 'children'){@inheritDoc}
Parameters
- 
                $idPath
- 
                $parentPath
- 
                $nestingKey optional
reduce() ¶ public
reduce(callable $c, mixed $zero = null){@inheritDoc}
Parameters
- 
                callable$c
- 
                $zero optional
reject() ¶ public
reject(callable $c): Cake\Collection\Iterator\FilterIterator{@inheritDoc}
Parameters
- 
                callable$c
Returns
Cake\Collection\Iterator\FilterIteratorsortBy() ¶ public
sortBy(mixed $callback, mixed $dir = SORT_DESC, mixed $type = SORT_NUMERIC){@inheritDoc}
Parameters
- 
                $callback
- 
                $dir optional
- 
                $type optional
stopWhen() ¶ public
stopWhen(mixed $condition): Cake\Collection\Iterator\StoppableIterator{@inheritDoc}
Parameters
- 
                $condition
Returns
Cake\Collection\Iterator\StoppableIteratortake() ¶ public
take(mixed $size = 1, mixed $from = 0){@inheritDoc}
Parameters
- 
                $size optional
- 
                $from optional
toArray() ¶ public
toArray(mixed $preserveKeys = true){@inheritDoc}
Parameters
- 
                $preserveKeys optional
transpose() ¶ public
transpose(): Cake\Collection\CollectionInterface{@inheritDoc}
Returns
Cake\Collection\CollectionInterfaceunfold() ¶ public
unfold(callable $transformer = null){@inheritDoc}
Parameters
- 
                callable$transformer optional
Property Detail
$_spacer ¶ protected
The string to use for prefixing the values according to their depth in the tree.
Type
string