private static function normalizePath($uri, $path = null)
    {
        if ($path instanceof PathInterface) {
            $path = $path->getContent();
        }

        $path = $path ?? $uri->getPath();
        $path = (string) $path;
        if (null !== $uri->getAuthority()
            && '' !== $uri->getAuthority()
            && '' !== $path
            && '/' != ($path[0] ?? '')
        ) {
            return $uri->withPath('/'.$path);
        }

        return $uri->withPath($path);
    }
private static function normalizePath($uri, $path = null)
    {
        if ($path instanceof PathInterface) {
            $path = $path->getContent();
        }

        $path = $path ?? $uri->getPath();
        $path = (string) $path;
        if (null !== $uri->getAuthority()
            && '' !== $uri->getAuthority()
            && '' !== $path
            && '/' != ($path[0] ?? '')
        ) {
            return $uri->withPath('/'.$path);
        }

        return $uri->withPath($path);
    }
private static function normalizePath ( $ uri , $ path = null ) { if ( $ path instanceof PathInterface ) { $ path = $ path -> getContent ( ) ; } $ path = $ path ?? $ uri -> getPath ( ) ; $ path = ( string ) $ path ; if ( null !== $ uri -> getAuthority ( ) && '' !== $ uri -> getAuthority ( ) && '' !== $ path && '/' != ( $ path [ 0 ] ?? '' ) ) { return $ uri -> withPath ( '/' . $ path ) ; } return $ uri -> withPath ( $ path ) ; }
Normalize a URI path.

Make sure the path always has a leading slash if an authority is present
and the path is not the empty string.

@param null|string|PathInterface $path

@return Psr7UriInterface|UriInterface
Normalize a URI path .