mirror of
https://github.com/cerbero90/json-parser.git
synced 2025-01-17 04:58:15 +01:00
Traverse the parser via method chaining
This commit is contained in:
parent
76904d3768
commit
bdb20ff836
@ -141,6 +141,21 @@ final class JsonParser implements IteratorAggregate
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Traverse the lazily iterable JSON
|
||||
*
|
||||
* @param Closure|null $callback
|
||||
* @return void
|
||||
*/
|
||||
public function traverse(Closure $callback = null): void
|
||||
{
|
||||
$callback ??= fn () => true;
|
||||
|
||||
foreach ($this as $key => $value) {
|
||||
$callback($value, $key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the lazily iterable JSON
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user