public function set(string $uri, int $method, callable $action, bool $default = false): self
    {
        if ((self::METHOD_ANY & $method) !== $method) {
            throw new Exception\InvalidMethodException(
                "Route does not contain a valid HTTP Method."
            );
        }

        $this->uri = "~";
        foreach (explode("|", $uri) as $uri) {
            $uri = trim($uri, "^$");
            // add /? to every uri that does not already end with a /<quaantifier>
            $this->uri .= "^" . preg_replace("~/$|(?:(?<!/)[+*?]|[^+*?])\K$~", "/?", $uri) . "$|";
        }
        $this->uri = rtrim($this->uri, "|") . "~";
        $this->method = $method;
        $this->action = $action;
        $this->isDefault = $default;

        return $this;
    }