public function setPath(string $path)
    {
        $path = '/' . ltrim($path, '/');
        $this->query = null;
        $this->fragment = null;
        if (preg_match('/^(.*?)(\\?([^#]*))?(#(.*))?$/u', $path, $matches))
        {
            $path = $matches[1];
            $this->query = !empty($matches[3]) ? $matches[3] : null;
            $this->fragment = !empty($matches[5]) ? $matches[5] : null;
        }

        $this->path = $path;
        return $this;
    }
public function setPath(string $path)
    {
        $path = '/' . ltrim($path, '/');
        $this->query = null;
        $this->fragment = null;
        if (preg_match('/^(.*?)(\\?([^#]*))?(#(.*))?$/u', $path, $matches))
        {
            $path = $matches[1];
            $this->query = !empty($matches[3]) ? $matches[3] : null;
            $this->fragment = !empty($matches[5]) ? $matches[5] : null;
        }

        $this->path = $path;
        return $this;
    }
public function setPath ( string $ path ) { $ path = '/' . ltrim ( $ path , '/' ) ; $ this -> query = null ; $ this -> fragment = null ; if ( preg_match ( '/^(.*?)(\\?([^#]*))?(#(.*))?$/u' , $ path , $ matches ) ) { $ path = $ matches [ 1 ] ; $ this -> query = ! empty ( $ matches [ 3 ] ) ? $ matches [ 3 ] : null ; $ this -> fragment = ! empty ( $ matches [ 5 ] ) ? $ matches [ 5 ] : null ; } $ this -> path = $ path ; return $ this ; }
Set the path of the URL. This will unset the currently set
fragment and query and overwrite them with whatever is appended in the path.
@param string $path The path to set. May include query and fragment
@return URL Provides fluent interface
Set the path of the URL . This will unset the currently set fragment and query and overwrite them with whatever is appended in the path .