protected function buildNameIndex() : void
    {
        foreach ($this->routes as $key => $route) {
            if (! is_null($route->getName())) {
                unset($this->routes[$key]);
                $this->namedRoutes[$route->getName()] = $route;
            }
        }
    }