public function map(
        ?string $method,
        string $route,
        $controller,
        $middleware = [],
        string $domain = null,
        string $name = null
    ): Router {
        $name = $name ?: $this->currentName;
        $uri = $this->currentPrefix.$route;
        $middleware = is_array($middleware) ? $middleware : [$middleware];

        if (is_string($controller) && is_callable($controller) == false) {
            $controller = $this->currentNamespace."\\".$controller;
        }

        $route = new Route(
            $name,
            $uri,
            $method,
            $controller,
            array_merge($this->currentMiddleware, $middleware),
            $domain ?: $this->currentDomain
        );

        $this->routes[] = $route;

        if ($name) {
            $this->names[$name] = $route;
            $this->currentName = null;
        }

        return $this;
    }