public function route(string $method, string $path): Route
    {
        if (!HttpMethod::isValid($method)) {
            throw new \InvalidArgumentException("Invalid HTTP method '$method'");
        }

        $this->allowedMethods = [];

        $segments = split_segments($path);
        $routes = $this->matchRoutes($method, $segments);

        if (\count($routes) === 1) {
            return $routes[0];
        }

        if (\count($routes) !== 0) {
            throw new \UnexpectedValueException("The given path '$path' matches more than one route");
        }

        if (\count($this->allowedMethods) > 0) {
            if (\in_array(HttpMethod::GET, $this->allowedMethods, true)) {
                $this->allowedMethods[] = HttpMethod::HEAD;
            }

            throw new MethodNotAllowedException(
                "The requested method '$method' is not within list of allowed methods",
                array_values(array_intersect(HttpMethod::getAll(), $this->allowedMethods))
            );
        }

        throw new RouteNotFoundException("The given path '$path' did not match any defined route");
    }