From 6ad39e3ba64e518bcdba1fc32b6247375be39a8a Mon Sep 17 00:00:00 2001 From: Sam Light Date: Wed, 10 Jun 2026 19:00:32 +0100 Subject: shared code in traits for common features for groups --- src/PathSegment.php | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) (limited to 'src/PathSegment.php') 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 */ 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); -- cgit v1.2.3