getDirectory.php
Table of Contents
Functions
- getDirectory() : string
- Normalises (and optionally validates) a directory path.
Functions
getDirectory()
Normalises (and optionally validates) a directory path.
getDirectory(string|array<string|int, mixed>|null $path[, bool $assertable = true ][, bool $isReadable = true ][, bool $isWritable = false ]) : string
- If
$path
is an array, empty segments andChar::EMPTY
are removed, then the remaining parts are joined withDIRECTORY_SEPARATOR
. - If
$assertable
is true (default), assertDirectory() ensures the resulting path exists and is readable. - Trailing separators are always stripped before return.
Parameters
- $path : string|array<string|int, mixed>|null
-
Directory or segments to normalise.
Examples:'/tmp'
or['tmp','logs']
. - $assertable : bool = true
-
Whether to validate the resulting path. Default: true.
- $isReadable : bool = true
-
Whether to assert that the directory is readable. Default: true.
- $isWritable : bool = false
-
Whether to assert that the directory is writable. Default: false.
Tags
Return values
string —Normalized directory path.