Documentation

AbsolutePath
in package
implements AbsolutePathInterface Uses AbsolutePathFromCurrentDirTrait

Represent and manipulate unixoid paths as immutables.

Tags
TODO

PHP 8.2 baseline: Make readonly

immutable

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
readonly

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
throws
ValueError
Return values
mixed

__toString()

public __toString() : string
Return values
string

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

Search results