Filesystem
in package
implements
FilesystemInterface
Class Filesystem
Table of Contents
Interfaces
- FilesystemInterface
- Defines several stream-save filesystem actions.
Properties
- $default : static|null
- $safe : static|null
- $unsafe : static|null
- $normalize : bool|null
Methods
- basename() : string
- Unicode-safe and stream-safe `\basename()` replacement.
- dirname() : string
- Unicode-safe and stream-safe `\dirname()` replacement.
- getInstance() : Filesystem
- getNormalization() : bool|null
- normalize() : string
- Normalize path by cleaning up `\`, `/./`, `//` and `/../`.
- parent() : string
- Get parent path. Empty path is returned if there are no segments remaining.
- pathinfo() : array<string|int, mixed>|string
- Unicode-safe and stream-safe `\pathinfo()` replacement.
- pathname() : string
- Gets full path with trailing slash.
- safe() : self
- Force all paths not to be normalized (speeds up the calls if given paths are known to be normalized).
- setNormalization() : Filesystem
- Set path normalization.
- unsafe() : self
- Force all paths to be normalized.
- dirnameInternal() : array<string|int, mixed>
- getSchemeAndHierarchy() : array<string|int, mixed>
- Gets a 2-tuple of scheme (may be null) and hierarchical part of a filename (e.g. file:///tmp -> array(file, tmp)).
- normalizePathPart() : string
- pathinfoInternal() : array<string|int, mixed>|string
- toString() : string
Properties
$default
protected
static static|null
$default
$safe
protected
static static|null
$safe
$unsafe
protected
static static|null
$unsafe
$normalize
private
bool|null
$normalize
Methods
basename()
Unicode-safe and stream-safe `\basename()` replacement.
public
basename(string $path[, string|null $suffix = null ]) : string
Parameters
- $path : string
-
A filename or path, does not need to exist as a file.
- $suffix : string|null = null
-
If the filename ends in suffix this will also be cut off.
Tags
Return values
stringdirname()
Unicode-safe and stream-safe `\dirname()` replacement.
public
dirname(string $path[, int $levels = 1 ]) : string
Parameters
- $path : string
-
A filename or path, does not need to exist as a file.
- $levels : int = 1
-
The number of parent directories to go up (>= 1).
Tags
Return values
string —Returns path to the directory.
getInstance()
public
static getInstance([bool|null $normalize = null ]) : Filesystem
Parameters
- $normalize : bool|null = null
-
See $this->setNormalization()
Return values
FilesystemgetNormalization()
public
getNormalization() : bool|null
Return values
bool|nullnormalize()
Normalize path by cleaning up `\`, `/./`, `//` and `/../`.
public
normalize(string $path) : string
Parameters
- $path : string
-
A filename or path, does not need to exist as a file.
Tags
Return values
string —Returns normalized path.
parent()
Get parent path. Empty path is returned if there are no segments remaining.
public
parent(string $path[, int $levels = 1 ]) : string
Parameters
- $path : string
-
A filename or path, does not need to exist as a file.
- $levels : int = 1
-
The number of parent directories to go up (>= 1).
Tags
Return values
string —Returns parent path.
pathinfo()
Unicode-safe and stream-safe `\pathinfo()` replacement.
public
pathinfo(string $path[, int|null $options = null ]) : array<string|int, mixed>|string
Parameters
- $path : string
-
A filename or path, does not need to exist as a file.
- $options : int|null = null
-
A PATHINFO_* constant.
Tags
Return values
array<string|int, mixed>|stringpathname()
Gets full path with trailing slash.
public
pathname(string $path[, int $levels = 1 ]) : string
Parameters
- $path : string
- $levels : int = 1
Tags
Return values
stringsafe()
Force all paths not to be normalized (speeds up the calls if given paths are known to be normalized).
public
safe() : self
Return values
selfsetNormalization()
Set path normalization.
public
setNormalization([bool|null $normalize = null ]) : Filesystem
Default option enables normalization for the streams only, but you can force the normalization to be either on or off for every path. Disabling path normalization speeds up the calls, but may cause issues if paths were not normalized.
Parameters
- $normalize : bool|null = null
Return values
Filesystemunsafe()
Force all paths to be normalized.
public
unsafe() : self
Return values
selfdirnameInternal()
protected
dirnameInternal(string|null $scheme, string $path[, int $levels = 1 ]) : array<string|int, mixed>
Parameters
- $scheme : string|null
- $path : string
- $levels : int = 1
Tags
Return values
array<string|int, mixed>getSchemeAndHierarchy()
Gets a 2-tuple of scheme (may be null) and hierarchical part of a filename (e.g. file:///tmp -> array(file, tmp)).
protected
getSchemeAndHierarchy(string $filename) : array<string|int, mixed>
Parameters
- $filename : string
Return values
array<string|int, mixed>normalizePathPart()
protected
normalizePathPart(string $path) : string
Parameters
- $path : string
Tags
Return values
stringpathinfoInternal()
protected
pathinfoInternal(string|null $scheme, string $path[, int|null $options = null ]) : array<string|int, mixed>|string
Parameters
- $scheme : string|null
- $path : string
- $options : int|null = null
Return values
array<string|int, mixed>|stringtoString()
protected
toString(string|null $scheme, string $path) : string
Parameters
- $scheme : string|null
- $path : string