Iterate through the original tree

This commit is contained in:
Andrea Marco Sartori 2022-12-03 20:29:47 +10:00
parent ab8c10c05d
commit 54b19eb70b
2 changed files with 2 additions and 14 deletions

View File

@ -54,7 +54,7 @@ class Pointers implements Countable
$pointers = [];
foreach ($this->pointers as $pointer) {
foreach ($tree as $depth => $key) {
foreach ($tree->original() as $depth => $key) {
if (!$pointer->depthMatchesKey($depth, $key)) {
continue 2;
} elseif (!isset($pointers[$depth])) {

View File

@ -3,14 +3,12 @@
namespace Cerbero\JsonParser;
use Cerbero\JsonParser\Pointers\Pointer;
use IteratorAggregate;
use Traversable;
/**
* The JSON tree.
*
*/
class Tree implements IteratorAggregate
class Tree
{
/**
* The original JSON tree.
@ -135,14 +133,4 @@ class Tree implements IteratorAggregate
return is_string($key) ? "\"$key\"" : $key;
}
/**
* Retrieve the original tree iterator
*
* @return Traversable
*/
public function getIterator(): Traversable
{
yield from $this->original();
}
}