\Omega\Filesystem\Util Path

Class Path.

The Path class provides utility methods for handling and manipulating file system paths in a consistent manner. It includes functionalities for normalizing paths, checking if a path is absolute, and extracting the directory name from a path. This class is designed to facilitate operations on paths in a cross-platform manner, ensuring that path manipulations conform to UNIX-style conventions.

Summary

Methods
Properties
Constants
normalize
isAbsolute
getAbsolutePrefix
dirname
No public properties found
No public constants found
No protected methods found
No protected properties found
No protected constants found
No private methods found
No private properties found
No private constants found

Methods

normalize()

normalize(string  $path) : string

Normalizes the given path by resolving relative path segments (like "." and "..") and converting backslashes to slashes. The normalization process removes any redundant separators and ensures that the path is clean and usable.

Parameters

string $path

The path to normalize.

Returns

string —

The normalized path.

isAbsolute()

isAbsolute(string  $path) : bool

Indicates whether the given path is absolute or not.

An absolute path is one that starts from the root directory, while a relative path starts from the current working directory.

Parameters

string $path

A normalized path.

Returns

bool —

Returns true if the path is absolute, false otherwise.

getAbsolutePrefix()

getAbsolutePrefix(string  $path) : string

Returns the absolute prefix of the given path.

The absolute prefix can include the drive letter and protocol for paths in certain operating systems (like Windows).

Parameters

string $path

A normalized path.

Returns

string —

The absolute prefix of the path.

dirname()

dirname(string  $path) : string

Wraps the native dirname function to handle only UNIX-style paths.

This method returns the directory name of the given path. It ensures that the path is treated as a UNIX-style path, replacing any backslashes with slashes.

Parameters

string $path

The path from which to extract the directory name.

Returns

string —

The directory name of the path.