unrealmanu / abstract-walker
walker recursive abstract helper
0.0.4
2020-03-22 11:44 UTC
Requires
- php: ^7.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.1
- phpunit/phpunit: ^9
This package is auto-updated.
Last update: 2025-02-22 23:09:22 UTC
README
Manuel Trebbi unrealmanumaster@gmail.com
Walk on the deepest level of object or array with filter by instance and control of deep level
CMD LIST
Launch TEST:
composer test tests
Fix LINT
composer fix tests
composer fix src
Install GIT-HOOK
./scripts/install-hook.bash
USAGE
Extends unrealmanu\Walker\AbstractWalker
example:
- ./tests/Walk.php
Necessary Method
abstract function loadChildren(array $parent): array; /** * @param $parent * @return array */ public function walk($parent): array; /** * @param $parent * @return Generator */ public function walkGen($parent): Generator;
METHOD
Define action to get object/array childrens and return this
LoadChidren($parent)
Return array of walked elements
walk($parent) [low performance - easy to use and check]
Return the "raw" generator used for walking in the deepest of elements...
walkGen($parent) [best perfomance]
OPTIONS
unrealmanu\Walker\DTO\WalkOptions (predefined)
unrealmanu\Walker\DTO\WalkOptionsInterface (for future implementation)
true = recursive, false = stop in first depth level
public function setRecursiveProcessStatus(bool $status = true): bool;
Set Class instance for filter the children in walking process
public function setFilterInstance(array $class): array;
Set the limit of deepest recursion level
public function setRecursiveDepthLimit(int $recursiveDepthLimit): void;
Make your custom logic filter for item in recursive processes
public function itemFilter($item): bool