Path Interfaces ############### PathInterface ============= ``resolveRelative()`` --------------------- .. code-block:: php resolveRelative($rel1); // /some/other/path // trailing slash will be present if target path has it $rel1->resolveRelative($rel2); // ../other/diff/path/ Strict mode throws exception if traversal happens beyond root (no effect if the base path is relative): .. code-block:: php resolveRelative($rel); // /etc/passwd $path->resolveRelative($rel, strict: true); // exception ``getPrefix()`` --------------- Path prefix that you can't traverse beyond like root unix path, windows drive path (C:\\), and url hostname. ``getComponents()`` ------------------- An array of path components excluding prefix. The last component of the path is empty string if path has trailing (back)slash ``isAbsolute()`` ---------------- ``true`` for instances of ``AbsolutePathInterface``. ``false`` for instances of ``RelativePathInterface``. ``isRelative()`` ---------------- ``false`` for instances of ``AbsolutePathInterface``. ``true`` for instances of ``RelativePathInterface``. ``toString()`` & ``__toString()`` --------------------------------- Get string value of the path. AbsolutePathInterface ===================== ``makeRelative()`` ------------------ .. code-block:: php makeRelative($path2); // ../sandfox/ // ignore case on Windows $path1 = WindowsPath::parse('c:\users\arokettu'); $path2 = WindowsPath::parse('C:\Users\SandFox'); $path1->makeRelative( $path2, fn ($a, $b) => strtoupper($a) === strtoupper($b) ); // ..\SandFox // resolve urlencoded url path $path1 = UrlPath::parse('https://example.com/some%20path/child%20dir'); $path2 = UrlPath::parse('https://example.com/some path/child dir'); $path1->makeRelative( $path2, fn ($a, $b) => urldecode($a) === urldecode($b) ); // . RelativePathInterface ===================== ``isRoot()`` ------------ ``true`` if the relative path is 'root path', i.e. full path excluding prefix. Examples: * ``\Users\SandFox`` for Windows path ``C:\Users\SandFox`` * ``/some path/child dir`` for UrlPath ``https://example.com/some path/child dir`` * Functionally equal to Unix path When applying root path in ``resolveRelative()``, it replaces the whole path excluding prefix.