summaryrefslogtreecommitdiff
path: root/src/PathSegment.php
diff options
context:
space:
mode:
authorSam Light <sam@lightscale.co.uk>2026-06-10 19:00:32 +0100
committerSam Light <sam@lightscale.co.uk>2026-06-10 19:00:32 +0100
commit6ad39e3ba64e518bcdba1fc32b6247375be39a8a (patch)
treecc7ba7901043428b327d454580460e7b67c399b9 /src/PathSegment.php
parent9e6a18235564df5046c40570a864bcbd5c8bcf62 (diff)
shared code in traits for common features for groups
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);