From 14cd1cc59f1c62cbc705d82e0947b52121f79b95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Fri, 27 Jan 2023 17:06:59 +0100 Subject: [PATCH] Fix: Add root() to NodeInterface --- CHANGELOG.md | 2 ++ src/Node/NodeInterface.php | 7 +++++++ src/Node/NodeTrait.php | 5 ----- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24b52a2..2c1059b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ For a full diff see [`0.5.0...master`][0.5.0...master]. ### Changed - Added `getSize()` to `NodeInterface` ([#147]), by [@localheinz] +- Added `root()` to `NodeInterface` ([#148]), by [@localheinz] ## [`0.5.0`][0.5.0] @@ -205,6 +206,7 @@ For a full diff see [`fcfd14e...v0.1.1`][fcfd14e...0.1.1]. [#137]: https://github.com/nicmart/Tree/pull/137 [#138]: https://github.com/nicmart/Tree/pull/138 [#147]: https://github.com/nicmart/Tree/pull/147 +[#148]: https://github.com/nicmart/Tree/pull/148 [@asalazar-pley]: https://github.com/asalazar-pley [@Djuki]: https://github.com/Djuki diff --git a/src/Node/NodeInterface.php b/src/Node/NodeInterface.php index 507e696..58a960f 100644 --- a/src/Node/NodeInterface.php +++ b/src/Node/NodeInterface.php @@ -136,6 +136,13 @@ public function isChild(); */ public function isLeaf(); + /** + * Find the root of the node. + * + * @return NodeInterface + */ + public function root(); + /** * Return the distance from the current node to the root. * diff --git a/src/Node/NodeTrait.php b/src/Node/NodeTrait.php index 6c6c1a2..8db5bcd 100644 --- a/src/Node/NodeTrait.php +++ b/src/Node/NodeTrait.php @@ -151,11 +151,6 @@ public function isLeaf() return 0 === \count($this->children); } - /** - * Find the root of the node. - * - * @return NodeInterface - */ public function root() { $node = $this;