public function toRelative(\Coast\Path $base)
    {
        if (!$this->isAbsolute() || !$base->isAbsolute()) {
            throw new \Exception("Source path '{$this}' is not absolute or base path '{$base}' is not absolute");
        }
        
        $source = explode('/', (string) $base);
        $target = explode('/', $this->_name);

        $name = $target;
        foreach ($source as $i => $part) {
            if ($part == $target[$i]) {
                array_shift($name);
            } else {
                $name = array_pad($name, (count($name) + (count($source) - $i) - 1) * -1, '..');
                break;
            }
        }
        $name = implode('/', $name);

        $class = get_class($this);
        return new $class($name);
    }
public function toRelative(\Coast\Path $base)
    {
        if (!$this->isAbsolute() || !$base->isAbsolute()) {
            throw new \Exception("Source path '{$this}' is not absolute or base path '{$base}' is not absolute");
        }
        
        $source = explode('/', (string) $base);
        $target = explode('/', $this->_name);

        $name = $target;
        foreach ($source as $i => $part) {
            if ($part == $target[$i]) {
                array_shift($name);
            } else {
                $name = array_pad($name, (count($name) + (count($source) - $i) - 1) * -1, '..');
                break;
            }
        }
        $name = implode('/', $name);

        $class = get_class($this);
        return new $class($name);
    }
public function toRelative ( \ Coast \ Path $ base ) { if ( ! $ this -> isAbsolute ( ) || ! $ base -> isAbsolute ( ) ) { throw new \ Exception ( "Source path '{$this}' is not absolute or base path '{$base}' is not absolute" ) ; } $ source = explode ( '/' , ( string ) $ base ) ; $ target = explode ( '/' , $ this -> _name ) ; $ name = $ target ; foreach ( $ source as $ i => $ part ) { if ( $ part == $ target [ $ i ] ) { array_shift ( $ name ) ; } else { $ name = array_pad ( $ name , ( count ( $ name ) + ( count ( $ source ) - $ i ) - 1 ) * - 1 , '..' ) ; break ; } } $ name = implode ( '/' , $ name ) ; $ class = get_class ( $ this ) ; return new $ class ( $ name ) ; }
Get relative path from absolute path.
@param  Coast\Path $base Base absolute path.
@return Coast\Path
Get relative path from absolute path .