From 54b19eb70b18d731139105c4c9a615ee24ef33f0 Mon Sep 17 00:00:00 2001 From: Andrea Marco Sartori Date: Sat, 3 Dec 2022 20:29:47 +1000 Subject: [PATCH] Iterate through the original tree --- src/Pointers/Pointers.php | 2 +- src/Tree.php | 14 +------------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/Pointers/Pointers.php b/src/Pointers/Pointers.php index babce37..2ba06a7 100644 --- a/src/Pointers/Pointers.php +++ b/src/Pointers/Pointers.php @@ -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])) { diff --git a/src/Tree.php b/src/Tree.php index 5b59362..d126001 100644 --- a/src/Tree.php +++ b/src/Tree.php @@ -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(); - } }