src/Domain/Value/Identifier/Uri.php
protected static function removeDotSegments(string $path): string
    {
        $output = '';
        while ($path) {
            if ('..' == $path || '.' == $path) {
                break;
            }
            switch (true) {
                case ('./' == substr($path, 0, 2)):
                    $path = substr($path, 2);
                    break;
                case ('../' == substr($path, 0, 3)):
                    $path = substr($path, 3);
                    break;
                case ('/./' == substr($path, 0, 3)):
                    $path = substr($path, 2);
                    break;
                case ('/../' == substr($path, 0, 4)):
                    $path = '/'.substr($path, 4);
                    $pos = strrpos($output, '/', -1);
                    if ($pos !== false) {
                        $output = substr($output, 0, $pos);
                    }
                    break;
                case ('/..' == substr($path, 0, 3) && (in_array(substr($path, 3, 1), [false, '', '/'], true))):
                    $path = '/'.substr($path, 3);
                    $pos = strrpos($output, '/', -1);
                    if ($pos !== false) {
                        $output = substr($output, 0, $pos);
                    }
                    break;
                case ('/.' == substr($path, 0, 2) && (in_array(substr($path, 2, 1), [false, '', '/'], true))):
                    $path = '/'.substr($path, 2);
                    break;
                default:
                    $nextSlash = strpos($path, '/', 1);
                    if (false === $nextSlash) {
                        $segment = $path;
                    } else {
                        $segment = substr($path, 0, $nextSlash);
                    }
                    $output .= $segment;
                    $path = substr($path, strlen($segment));
                    break;
            }
        }

        return $output;
    }
protected static function removeDotSegments(string $path): string
    {
        $output = '';
        while ($path) {
            if ('..' == $path || '.' == $path) {
                break;
            }
            switch (true) {
                case ('./' == substr($path, 0, 2)):
                    $path = substr($path, 2);
                    break;
                case ('../' == substr($path, 0, 3)):
                    $path = substr($path, 3);
                    break;
                case ('/./' == substr($path, 0, 3)):
                    $path = substr($path, 2);
                    break;
                case ('/../' == substr($path, 0, 4)):
                    $path = '/'.substr($path, 4);
                    $pos = strrpos($output, '/', -1);
                    if ($pos !== false) {
                        $output = substr($output, 0, $pos);
                    }
                    break;
                case ('/..' == substr($path, 0, 3) && (in_array(substr($path, 3, 1), [false, '', '/'], true))):
                    $path = '/'.substr($path, 3);
                    $pos = strrpos($output, '/', -1);
                    if ($pos !== false) {
                        $output = substr($output, 0, $pos);
                    }
                    break;
                case ('/.' == substr($path, 0, 2) && (in_array(substr($path, 2, 1), [false, '', '/'], true))):
                    $path = '/'.substr($path, 2);
                    break;
                default:
                    $nextSlash = strpos($path, '/', 1);
                    if (false === $nextSlash) {
                        $segment = $path;
                    } else {
                        $segment = substr($path, 0, $nextSlash);
                    }
                    $output .= $segment;
                    $path = substr($path, strlen($segment));
                    break;
            }
        }

        return $output;
    }
protected static function removeDotSegments ( string $ path ) : string { $ output = '' ; while ( $ path ) { if ( '..' == $ path || '.' == $ path ) { break ; } switch ( true ) { case ( './' == substr ( $ path , 0 , 2 ) ) : $ path = substr ( $ path , 2 ) ; break ; case ( '../' == substr ( $ path , 0 , 3 ) ) : $ path = substr ( $ path , 3 ) ; break ; case ( '/./' == substr ( $ path , 0 , 3 ) ) : $ path = substr ( $ path , 2 ) ; break ; case ( '/../' == substr ( $ path , 0 , 4 ) ) : $ path = '/' . substr ( $ path , 4 ) ; $ pos = strrpos ( $ output , '/' , - 1 ) ; if ( $ pos !== false ) { $ output = substr ( $ output , 0 , $ pos ) ; } break ; case ( '/..' == substr ( $ path , 0 , 3 ) && ( in_array ( substr ( $ path , 3 , 1 ) , [ false , '' , '/' ] , true ) ) ) : $ path = '/' . substr ( $ path , 3 ) ; $ pos = strrpos ( $ output , '/' , - 1 ) ; if ( $ pos !== false ) { $ output = substr ( $ output , 0 , $ pos ) ; } break ; case ( '/.' == substr ( $ path , 0 , 2 ) && ( in_array ( substr ( $ path , 2 , 1 ) , [ false , '' , '/' ] , true ) ) ) : $ path = '/' . substr ( $ path , 2 ) ; break ; default : $ nextSlash = strpos ( $ path , '/' , 1 ) ; if ( false === $ nextSlash ) { $ segment = $ path ; } else { $ segment = substr ( $ path , 0 , $ nextSlash ) ; } $ output .= $ segment ; $ path = substr ( $ path , strlen ( $ segment ) ) ; break ; } } return $ output ; }
Removes dot segments

Algorithm based on section 5.2.4 of RFC 3986.

@link http://tools.ietf.org/html/rfc3986#section-5.2.4

@param string $path The input path

@return string
Removes dot segments