Path
MMO\core\helpers ยท 1 symbol ยท generated 30 Sep 2026
Path
Path.php:32- Namespace
MMO\core\helpers- Implements
- iArray, iRenderable
Index
| ABS_FILENAME | get absolute filename | |
| BASENAME | get only the file's name and extension | |
| BASE_PATH | include url base path | |
| EXTENSION | include url extension | |
| FILE | include url file | |
| PATH | get only the file's path | |
| REL_FILENAME | get only the relative filename | |
| REL_PATH | include url relative path | |
| STATUS_WINDOWS | ||
| base | ||
| content | ||
| immutable | ||
| windows | ||
| addPath($path) | Append $path (via merge, which resolves any '..'/'.' against the existing content). | |
| clear() | Empty this path entirely. | |
| count() | \Countable::count | |
| debugName() | ||
| empty() | ||
| flags() | Get set parts of the filename | |
| FlagsText($flags, $sep) static | Convert binary url flags to list of strings | |
| getBaseIndex() | ||
| getBasename() | Get the filename on the path | |
| getBasepath($join) | Get the basepath. If non empty, it is always returned with en ending '/' | |
| getExtension() | ||
| getFile() | ||
| getIterator() | \IteratorAggregate::getIterator | |
| getRelpath($join) | Get the relative part of the path | |
| getSimplified($join) | ||
| hasBasename() | Tells if path has a filename at the end of its path | |
| hasBasepath() | ||
| hasRelpath($strict) | ||
| Immutable($path, $root, $isWindows) static | Same as the constructor, but the returned Path is isImmutable. | |
| isAbsolute() | ||
| isImmutable() | ||
| isWindows() | ||
| jsonSerialize() | ||
| offsetExists($key) | \ArrayAccess::offsetExists | |
| offsetGet($key) | \ArrayAccess::offsetGet -- a negative $key counts from the end (-1 is the last segment). | |
| offsetSet($key, $value) | \ArrayAccess::offsetSet -- a negative $key counts from the end, like offsetGet; null appends. | |
| offsetUnset($key) | \ArrayAccess::offsetUnset -- a negative $key counts from the end, like offsetGet. | |
| rebase($root) | Make path absolute to a root. | |
| relativeTo($root, $strict) | Make path relative to a root | |
| removePath($number) | Remove the last $number segments. | |
| render($opts) | Render the path | |
| set($path) | Set the whole path and reset the basepath | |
| setBaseIndex($index) | Set the base index (used internally) | |
| setBasename($file) | Replace the last segment (the filename, if any) with $file. | |
| setBasepath($path) | Set the basepath, keeping the existing relative path. | |
| setExtension($ext) | Replace the filename's extension, keeping its name. | |
| setFile($file) | Replace the filename's name, keeping its extension. | |
| setRelpath($path) | Set the relative part of the path, keeping the existing basepath. | |
| setWindows($value) | ||
| simplify() | Simplifies path, removing `, .. and .` WARNING: change the basepath index if the simplified path reduced it | |
| slice($offset, $length, $join) | ||
| toArray() | ||
| toImmutable($forceClone) | ||
| toMutable($forceClone) | ||
| __construct($path, $root, $isWindows) | constructor | |
| __toString() |
Constants9
ABS_FILENAME
get absolute filename
BASENAME
get only the file's name and extension
BASE_PATH
include url base path
EXTENSION
include url extension
FILE
include url file
PATH
get only the file's path
REL_FILENAME
get only the relative filename
REL_PATH
include url relative path
STATUS_WINDOWS
Properties4
base
- Type
- int
content
- Type
- array
immutable
- Type
- bool
windows
- Type
- bool
Methods46
addPath($path)
Path.php:350Append $path (via merge, which resolves any '..'/'.' against the existing content).
| $path | ||
| returns | void | |
| throws | if isImmutable |
clear()
Path.php:305Empty this path entirely.
| returns | void | |
| throws | if isImmutable |
count()
Path.php:581\Countable::count
| returns | int |
debugName()
Path.php:168| returns | string | e.g. '(path)/test/marc/lab' |
empty()
Path.php:148| returns | bool | true if this path has no segments at all |
flags()
Path.php:197Get set parts of the filename
| returns | int | $flags binary combination of self::* constant |
FlagsText($flags, $sep)
staticPath.php:179Convert binary url flags to list of strings
| $flags | the flags to test | |
| $sep = ',' | the separator to use to concat the values, or false to return as array | |
| returns |
getBaseIndex()
Path.php:227| returns | int | the segment index where the basepath ends and the relative path begins |
getBasename()
Path.php:285Get the filename on the path
getBasepath($join)
Path.php:213Get the basepath. If non empty, it is always returned with en ending '/'
getExtension()
Path.php:295getFile()
Path.php:290getIterator()
Path.php:597\IteratorAggregate::getIterator
| returns | Traversable |
getRelpath($join)
Path.php:249Get the relative part of the path
getSimplified($join)
Path.php:466hasBasename()
Path.php:274Tells if path has a filename at the end of its path
| returns | bool |
hasBasepath()
Path.php:222| returns | bool | true if getBaseIndex is greater than 0 |
hasRelpath($strict)
Path.php:264Immutable($path, $root, $isWindows)
staticPath.php:79Same as the constructor, but the returned Path is isImmutable.
isAbsolute()
Path.php:143| returns | bool | true if this path starts from the filesystem/URL root |
isImmutable()
Path.php:111| returns | bool | true if this Path rejects mutation (every setter throws eRuntime) |
isWindows()
Path.php:163| returns | bool |
jsonSerialize()
Path.php:153offsetExists($key)
Path.php:588\ArrayAccess::offsetExists
offsetGet($key)
Path.php:557\ArrayAccess::offsetGet -- a negative $key counts from the end (-1 is the last segment).
offsetSet($key, $value)
Path.php:565\ArrayAccess::offsetSet -- a negative $key counts from the end, like offsetGet; null appends.
offsetUnset($key)
Path.php:545\ArrayAccess::offsetUnset -- a negative $key counts from the end, like offsetGet.
rebase($root)
Path.php:523Make path absolute to a root.
| $root | self | array | string | bool | if true, use the whole path as basepath; if false, remove the basepath (getBaseIndex resets to 0/1 depending on isAbsolute); otherwise, re-root the path onto $root (relativeTo + setBasepath) |
| returns | void | |
| throws | if isImmutable |
relativeTo($root, $strict)
Path.php:502Make path relative to a root
| $root | self | array | string | the base path |
| $strict = false | bool | if true, path MUST be a valid descendant of root (.. forbidden). returns false if not. |
| returns | bool | false if could not make path relative to root |
| throws | if isImmutable |
removePath($number)
Path.php:367Remove the last $number segments.
| $number = 1 | int | |
| returns | void | |
| throws | if isImmutable |
render($opts)
Path.php:124Render the path
| $opts = [] | array | basepath: if false, remove the basepath if string, render the relative path compare to basepath |
| returns | string |
set($path)
Path.php:317Set the whole path and reset the basepath
| $path | self | array | string | |
| returns | void | |
| throws | if isImmutable |
setBaseIndex($index)
Path.php:382Set the base index (used internally)
| $index | int | must be within [0, count(this path's segments)] |
| returns | void | |
| throws | if isImmutable | |
| throws | if $index is out of range |
setBasename($file)
Path.php:428Replace the last segment (the filename, if any) with $file.
| $file | string | |
| returns | void | |
| throws | if isImmutable |
setBasepath($path)
Path.php:395Set the basepath, keeping the existing relative path.
| $path | self | array | string | |
| returns | void | |
| throws | if isImmutable |
setExtension($ext)
Path.php:456Replace the filename's extension, keeping its name.
| $ext | string | without the leading '.' |
| returns | void | |
| throws | if isImmutable, or if there is no existing filename to keep |
setFile($file)
Path.php:442Replace the filename's name, keeping its extension.
| $file | string | |
| returns | void | |
| throws | if isImmutable, or if there is no existing extension to keep |
setRelpath($path)
Path.php:412Set the relative part of the path, keeping the existing basepath.
| $path | self | array | string | |
| returns | void | |
| throws | if isImmutable |
setWindows($value)
Path.php:158simplify()
Path.php:477Simplifies path, removing `, .. and .` WARNING: change the basepath index if the simplified path reduced it
| returns | self | $this, for chaining |
| throws | if isImmutable |
slice($offset, $length, $join)
Path.php:238toArray()
Path.php:138| returns | array | the path split into segments, e.g. ['', 'test', 'marc', 'lab'] for '/test/marc/lab' |
toImmutable($forceClone)
Path.php:90toMutable($forceClone)
Path.php:101__construct($path, $root, $isWindows)
Path.php:67constructor