AbsolutePath
in package
implements
AbsolutePathInterface
Uses
AbsolutePathFromCurrentDirTrait
Represent and manipulate unixoid paths as immutables.
Tags
Interfaces, Classes, Traits and Enums
- AbsolutePathInterface
- Represents either an absolute or a relative Path
Table of Contents
- $path : string
- TODO PHP 8.1 make readonly
- __construct() : mixed
- Constructor.
- __toString() : string
- addTrailingSlash() : AbsolutePath
- fromCurrentDir() : AbsolutePathInterface
- levelUp() : AbsolutePath
- normalize() : AbsolutePath
- Normalize a path
- removeTrailingSlash() : AbsolutePath
Properties
$path read-only
TODO PHP 8.1 make readonly
private
string
$path
Tags
Methods
__construct()
Constructor.
public
__construct(string|Stringable $path) : mixed
No default on purpose.
use ::fromCurrentDir to get the absolute path to cwd. use '' or './' for the path relative to self
Parameters
- $path : string|Stringable
Tags
Return values
mixed —__toString()
public
__toString() : string
Return values
string —addTrailingSlash()
public
addTrailingSlash() : AbsolutePath
Return values
AbsolutePath —fromCurrentDir()
public
static fromCurrentDir() : AbsolutePathInterface
Return values
AbsolutePathInterface —levelUp()
public
levelUp([int $levels = 1 ]) : AbsolutePath
Parameters
- $levels : int = 1
Return values
AbsolutePath —normalize()
Normalize a path
public
normalize() : AbsolutePath
Remove noop . and // Remove ../ together with the preceding level unless it hits the root Remove trailing slashes unless it is the root slash.
Return values
AbsolutePath —removeTrailingSlash()
public
removeTrailingSlash() : AbsolutePath