lib/Uri.php
public function getRelated(Uri $baseUri)
    {
        $path = $baseUri->getPath();
        if (substr($this->getPath(), 0, strlen($path)) == $path) {
            $class = get_called_class();
            $uri = new $class('');
            $uri->fragment = $this->fragment;
            $uri->path = substr($this->getPath(), strlen($path));
            $uri->query = $this->query;
            return $uri;
        }
        return $this;
    }
public function getRelated(Uri $baseUri)
    {
        $path = $baseUri->getPath();
        if (substr($this->getPath(), 0, strlen($path)) == $path) {
            $class = get_called_class();
            $uri = new $class('');
            $uri->fragment = $this->fragment;
            $uri->path = substr($this->getPath(), strlen($path));
            $uri->query = $this->query;
            return $uri;
        }
        return $this;
    }
public function getRelated ( Uri $ baseUri ) { $ path = $ baseUri -> getPath ( ) ; if ( substr ( $ this -> getPath ( ) , 0 , strlen ( $ path ) ) == $ path ) { $ class = get_called_class ( ) ; $ uri = new $ class ( '' ) ; $ uri -> fragment = $ this -> fragment ; $ uri -> path = substr ( $ this -> getPath ( ) , strlen ( $ path ) ) ; $ uri -> query = $ this -> query ; return $ uri ; } return $ this ; }
Get new uri instance related to provided base

Current: http://user:password@example.com/path/path2?k=v#fragment
Base: /path/
Return: path2?k=v#fragment

@param Uri $baseUri Base uri
@return $this
Get new uri instance related to provided base