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;
    }
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;
    }
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 ; }
Set Route data

Sets the retrieved data to internal properties. Prior to setting, the
method is checked, that it is valid, and raises an
'InvalidMethodException' on error.

@param string $uri Request URI regex without delimiter
@param int $method HTTP Request Method, accepts METHODO_* constant
@param callable $action Route action
@param bool $default Should the route be marked as default. Default bool(false)
@return self
Set Route data