@param RouteCollection $routeCollection
@param string          $routeName

@return string
198518
public static function generate(RouteCollection $routeCollection, $routeName)
    {
        $flag = false;
        $index = 1;
        while ($flag === false) {
            if ($routeCollection->get($routeName)) {
                $routeName = $routeName.'_'.$index++;
            } else {
                $flag = true;
            }
        }

        return $routeName;
    }
1249586
private function groupStaticRoutes(RouteCollection $collection): array
    {
        $staticRoutes = $dynamicRegex = [];
        $dynamicRoutes = new RouteCollection();

        foreach ($collection->all() as $name => $route) {
            $compiledRoute = $route->compile();
            $staticPrefix = rtrim($compiledRoute->getStaticPrefix(), '/');
            $hostRegex = $compiledRoute->getHostRegex();
            $regex = $compiledRoute->getRegex();
            if ($hasTrailingSlash = '/' !== $route->getPath()) {
                $pos = strrpos($regex, '$');
                $hasTrailingSlash = '/' === $regex[$pos - 1];
                $regex = substr_replace($regex, '/?$', $pos - $hasTrailingSlash, 1 + $hasTrailingSlash);
            }

            if (!$compiledRoute->getPathVariables()) {
                $host = !$compiledRoute->getHostVariables() ? $route->getHost() : '';
                $url = $route->getPath();
                if ($hasTrailingSlash) {
                    $url = substr($url, 0, -1);
                }
                foreach ($dynamicRegex as list($hostRx, $rx, $prefix)) {
                    if (('' === $prefix || 0 === strpos($url, $prefix)) && preg_match($rx, $url) && (!$host || !$hostRx || preg_match($hostRx, $host))) {
                        $dynamicRegex[] = [$hostRegex, $regex, $staticPrefix];
                        $dynamicRoutes->add($name, $route);
                        continue 2;
                    }
                }

                $staticRoutes[$url][$name] = [$route, $hasTrailingSlash];
            } else {
                $dynamicRegex[] = [$hostRegex, $regex, $staticPrefix];
                $dynamicRoutes->add($name, $route);
            }
        }

        return [$staticRoutes, $dynamicRoutes];
    }
289370
private function filterRouteCollectionForPath(RouteCollection $routes, $path)
    {
        $result = new RouteCollection();
        foreach ($routes->getResources() as $resource) {
            $result->addResource($resource);
        }
        foreach ($routes->all() as $name => $route) {
            $routePath = $route->getPath();
            $p = strpos($routePath, '{');
            $skip = false;
            if ($p === false) {
                if ($routePath !== $path) {
                    $skip = true;
                }
            } elseif ($p > 0) {
                $routeFixedPath = substr($routePath, 0, $p);
                if (strpos($path, $routeFixedPath) !== 0) {
                    $skip = true;
                }
            }
            if ($skip === false) {
                $result->add($name, $route);
            }
        }

        return $result;
    }
264698
private function createRouteDefinition($routeName, Route $route)
    {
        if (null === $definition = $this->findRouteDefinitionByRouteName($routeName)) {
            $definition = new RouteDefinition($routeName, $this->resolveRouteOptions($route, $routeName));
            if (null === $parentRouteName = $definition->getParentRouteName()) {
                // If parent route name is null => home page child
                $definition->setParentRouteName($this->homeRouteName);
                $this->homeDefinition->appendChild($definition);
            } else {
                // Creates parent route definition if needed
                $parentRoute = $this->findRouteByName($parentRouteName);
                $parentDefinition = $this->createRouteDefinition($parentRouteName, $parentRoute);
                $parentDefinition->appendChild($definition);
            }
        }

        return $definition;
    }
422505
public function transform($routeDocuments)
    {
        $routeCollection = new RouteCollection();

        /** @var RouteDocumentInterface $routeDocument */
        foreach ($routeDocuments as $routeDocument) {
            $routeCollection->add($routeDocument->getName(), $this->routeTransformer->transform($routeDocument));
        }

        return $routeCollection;
    }
522373
protected static function createRouteUrl(
        ContainerInterface $container,
        string $routeName,
        array $placeholders = [],
        array $queryParams = []
    ): string {
        /** @var RouterInterface $router */
        $router = $container->get(RouterInterface::class);

        $hostUri = static::getHostUri($container);
        $url     = $router->get($hostUri, $routeName, $placeholders, $queryParams);

        return $url;
    }
1114092
protected function localizeCollectionLocaleParameter($prefix, RouteCollection $collection)
    {
        $localizedPrefixes = array();
        foreach ($collection->all() as $name => $route) {
            $locale = $route->getDefault(self::LOCALE_PARAM);
            if ($locale === null) {
                // No locale so nothing to do
                $routePrefix = $prefix;
            } else {
                // A locale was found so localize the prefix
                if (!isset($localizedPrefixes[$locale])) {
                    $localizedPrefixes[$locale] = preg_replace(static::LOCALE_REGEX, $locale, $prefix);
                }
                $routePrefix = $localizedPrefixes[$locale];
            }
            $route->setPath('/' . $routePrefix . $route->getPath());
        }
    }
1369162
public function getRouteCollection()
    {
        if (is_null($this->routeCollection)) {
            $this->routeCollection = new RouteCollection();
            $this->initRoutes();
        }

        return $this->routeCollection;
    }
147922
protected function buildRouteCacheFile(RouteCollection $routes)
    {
        $stub = $this->files->get(__DIR__.'/stubs/routes.stub');

        return str_replace('{{routes}}', base64_encode(serialize($routes)), $stub);
    }
979977
public function seeCurrentRouteIs($routeName)
    {
        $this->getRouteByName($routeName); // Fails if route does not exists

        $currentRoute = $this->app->request->route();
        $currentRouteName = $currentRoute ? $currentRoute->getName() : '';

        if ($currentRouteName != $routeName) {
            $message = empty($currentRouteName)
                ? "Current route has no name"
                : "Current route is \"$currentRouteName\"";
            $this->fail($message);
        }
    }
135475
public function RemoveRoute ($routeName) {
		$result = NULL;
		if (isset($this->routes[$routeName])) {
			$result = $this->routes[$routeName];
			unset($this->routes[$routeName]);
			$this->removeRouteFromGroup($result, $routeName);
			$controllerAction = $result->GetControllerAction();
			if (isset($this->urlRoutes[$routeName])) 
				unset($this->urlRoutes[$routeName]);
			if (isset($this->urlRoutes[$controllerAction])) 
				unset($this->urlRoutes[$controllerAction]);
			/** @var $currentRoute \MvcCore\Route */
			$currentRoute = & $this->currentRoute;
			if ($currentRoute->GetName() === $result->GetName())
				$this->currentRoute = NULL;
		}
		if (!$this->routes && $this->preRouteMatchingHandler === NULL) 
			$this->anyRoutesConfigured = FALSE;
		return $result;
	}
976034
public function & GetRoute ($routeName) {
		if (isset($this->routes[$routeName]))
			return $this->routes[$routeName];
		return NULL;
	}
689748
public function generate($routeName, array $parameters = [])
    {
        $route = $this->router->getRoute($routeName);

        $required = $route->getParameterPatterns();
        $missing  = array_diff_key($required, $parameters);

        if (!empty($missing)) {
            $parameters = $this->insertDefaultParameterValues($route, $missing, $parameters);
        }

        return $this->buildPath($route->getPath(), $parameters, array_keys($required));
    }
343702
private function getRouteByName($routeName)
    {
        if (isset($this->app->router) && $this->app->router instanceof \Laravel\Lumen\Routing\Router) {
            $router = $this->app->router;
        } else {
            // backward compatibility with lumen 5.3
            $router = $this->app;
        }
        foreach ($router->getRoutes() as $route) {
            if (isset($route['action']['as']) && $route['action']['as'] == $routeName) {
                return $route;
            }
        }
        $this->fail("Route with name '$routeName' does not exist");
        return null;
    }
1360813
public function registerRoutesCollection()
    {
        $this->app->singleton('routes.collection', function ($app) {
            return new RoutesCollection;
        });

        $this->app->alias('routes.collection', RoutesCollection::class);
    }
875352
protected function configureRoutes(RouteCollection $collection)
    {
        parent::configureRoutes($collection);

        $collection->add('moveUp', $this->getRouterIdParameter() . '/move-up');
        $collection->add('moveDown', $this->getRouterIdParameter() . '/move-down');
    }
777833
public function mapCollection(RouteCollection $restRouteCollection)
    {
        $optionsRouteCollection = new RouteCollection();

        foreach ($restRouteCollection->all() as $restRoute) {
            $optionsRouteName = $this->mapper->getOptionsRouteName($restRoute);

            $optionsRoute = $optionsRouteCollection->get($optionsRouteName);
            if ($optionsRoute === null) {
                $optionsRoute = $this->mapper->mapRoute($restRoute);
            } else {
                $optionsRoute = $this->mapper->mergeMethodsDefault($optionsRoute, $restRoute);
            }

            $optionsRouteCollection->add($optionsRouteName, $optionsRoute);
        }

        return $optionsRouteCollection;
    }