summaryrefslogtreecommitdiff
path: root/src/PathSegment.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/PathSegment.php')
-rw-r--r--src/PathSegment.php29
1 files changed, 1 insertions, 28 deletions
diff --git a/src/PathSegment.php b/src/PathSegment.php
index 2fc4cbb..01f3fc7 100644
--- a/src/PathSegment.php
+++ b/src/PathSegment.php
@@ -10,7 +10,7 @@ use Lightscale\Router\Exceptions\MissingParameterException;
class PathSegment
{
- private const MAX_ANCESTORY_DEPTH = 100;
+ use Concerns\HasAncestors;
/** @var array<string, self> */
protected array $children;
@@ -73,33 +73,6 @@ class PathSegment
return $this->parent;
}
- /** @return self[] */
- public function getAncestors(): array
- {
- $results = [];
-
- $count = 0;
- $instance = $this->parent;
- while (
- null !== $instance
- && $count++ < self::MAX_ANCESTORY_DEPTH
- ) {
- $results[] = $instance;
- $instance = $instance->parent;
- }
-
- return array_reverse($results);
- }
-
- /** @return self[] */
- public function getAncestorsAndSelf(): array
- {
- $results = $this->getAncestors();
- $results[] = $this;
-
- return $results;
- }
-
public function addChild(self $segment): void
{
$segment->setParent($this);