protected function relativizePath(string $path): string
    {
        $base_segments = $this->getSegments($this->base_uri->getPath());
        $target_segments = $this->getSegments($path);
        $target_basename = array_pop($target_segments);
        array_pop($base_segments);
        foreach ($base_segments as $offset => $segment) {
            if (!isset($target_segments[$offset]) || $segment !== $target_segments[$offset]) {
                break;
            }
            unset($base_segments[$offset], $target_segments[$offset]);
        }
        $target_segments[] = $target_basename;

        return $this->formatPath(
            str_repeat('../', count($base_segments)).implode('/', $target_segments)
        );
    }
protected function relativizePath(string $path): string
    {
        $base_segments = $this->getSegments($this->base_uri->getPath());
        $target_segments = $this->getSegments($path);
        $target_basename = array_pop($target_segments);
        array_pop($base_segments);
        foreach ($base_segments as $offset => $segment) {
            if (!isset($target_segments[$offset]) || $segment !== $target_segments[$offset]) {
                break;
            }
            unset($base_segments[$offset], $target_segments[$offset]);
        }
        $target_segments[] = $target_basename;

        return $this->formatPath(
            str_repeat('../', count($base_segments)).implode('/', $target_segments)
        );
    }
protected function relativizePath ( string $ path ) : string { $ base_segments = $ this -> getSegments ( $ this -> base_uri -> getPath ( ) ) ; $ target_segments = $ this -> getSegments ( $ path ) ; $ target_basename = array_pop ( $ target_segments ) ; array_pop ( $ base_segments ) ; foreach ( $ base_segments as $ offset => $ segment ) { if ( ! isset ( $ target_segments [ $ offset ] ) || $ segment !== $ target_segments [ $ offset ] ) { break ; } unset ( $ base_segments [ $ offset ] , $ target_segments [ $ offset ] ) ; } $ target_segments [ ] = $ target_basename ; return $ this -> formatPath ( str_repeat ( '../' , count ( $ base_segments ) ) . implode ( '/' , $ target_segments ) ) ; }
Relative the URI for a authority-less target URI

@param string $path

@return string
Relative the URI for a authority - less target URI