mirror of
https://github.com/cerbero90/json-parser.git
synced 2025-01-17 13:08:16 +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;
|
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
|
* Retrieve the lazily iterable JSON
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user