diff --git a/src/Urling/PartParsers/PathParser.php b/src/Urling/PartParsers/PathParser.php index e67284b..3eafb75 100644 --- a/src/Urling/PartParsers/PathParser.php +++ b/src/Urling/PartParsers/PathParser.php @@ -33,6 +33,29 @@ public function contains($needle): bool return $is_contains; } + /** + * Get routes after first(1) segment of routes string + * - $urling->url->routes->splice(1); + * + * Get one route starting on first segment - "ismaxim" + * - $urling->url->routes->splice(1, 1); + * + * @param int $offset + * @param int|null $length + * + * @return string + */ + public function splice(int $offset, $length = null): string + { + $routes = (array) $this->explode(); + + $splice = (!$length) + ? array_splice($routes, $offset) + : array_splice($routes, $offset, $length); + + return implode("/", $splice); + } + /** * @return array|array|null */