abstract class AbstractPath implements PathInterface
Abstract base class for implementing PathInterface.
Constants
ATOM_SEPARATOR |
The character used to separate path atoms.
|
EXTENSION_SEPARATOR |
The character used to separate path name atoms.
|
PARENT_ATOM |
The atom used to represent 'parent'.
|
SELF_ATOM |
The atom used to represent 'self'.
|
Methods
__construct(mixed<string> $atoms, boolean|null $hasTrailingSeparator = null)
Construct a new path instance. |
||
array<integer,string> |
atoms()
Get the atoms of this path. |
|
string |
atomAt(integer $index)
Get a single path atom by index. |
|
mixed |
atomAtDefault(integer $index, mixed $default = null)
Get a single path atom by index, falling back to a default if the index is undefined. |
|
array<integer,string> |
sliceAtoms(integer $index, integer|null $length = null)
Get a subset of the atoms of this path. |
|
boolean |
hasAtoms()
Determine if this path has any atoms. |
|
boolean |
hasTrailingSeparator()
Determine if this path has a trailing separator. |
|
string |
string()
Generate a string representation of this path. |
|
string |
__toString()
Generate a string representation of this path. |
|
string |
name()
Get this path's name. |
|
array<integer,string> |
nameAtoms()
Get this path's name atoms. |
|
string |
nameAtomAt(integer $index)
Get a single path name atom by index. |
|
mixed |
nameAtomAtDefault(integer $index, mixed $default = null)
Get a single path name atom by index, falling back to a default if the index is undefined. |
|
array<integer,string> |
sliceNameAtoms(integer $index, integer|null $length = null)
Get a subset of this path's name atoms. |
|
string |
nameWithoutExtension()
Get this path's name, excluding the last extension. |
|
string |
namePrefix()
Get this path's name, excluding all extensions. |
|
string|null |
nameSuffix()
Get all of this path's extensions. |
|
string|null |
extension()
Get this path's last extension. |
|
boolean |
hasExtension()
Determine if this path has any extensions. |
|
boolean |
contains(string $needle, boolean|null $caseSensitive = null)
Determine if this path contains a substring. |
|
boolean |
startsWith(string $needle, boolean|null $caseSensitive = null)
Determine if this path starts with a substring. |
|
boolean |
endsWith(string $needle, boolean|null $caseSensitive = null)
Determine if this path ends with a substring. |
|
boolean |
matches(string $pattern, boolean|null $caseSensitive = null, integer|null $flags = null)
Determine if this path matches a wildcard pattern. |
|
boolean |
matchesRegex(string $pattern, array $matches = null, integer|null $flags = null, integer|null $offset = null)
Determine if this path matches a regular expression. |
|
boolean |
nameContains(string $needle, boolean|null $caseSensitive = null)
Determine if this path's name contains a substring. |
|
boolean |
nameStartsWith(string $needle, boolean|null $caseSensitive = null)
Determine if this path's name starts with a substring. |
|
boolean |
nameMatches(string $pattern, boolean|null $caseSensitive = null, integer|null $flags = null)
Determine if this path's name matches a wildcard pattern. |
|
boolean |
nameMatchesRegex(string $pattern, array $matches = null, integer|null $flags = null, integer|null $offset = null)
Determine if this path's name matches a regular expression. |
|
PathInterface |
parent(integer|null $numLevels = null)
Get the parent of this path a specified number of levels up. |
|
PathInterface |
stripTrailingSlash()
Strips the trailing slash from this path. |
|
PathInterface |
stripExtension()
Strips the last extension from this path. |
|
PathInterface |
stripNameSuffix()
Strips all extensions from this path. |
|
PathInterface |
joinAtoms($atom)
Joins one or more atoms to this path. |
|
PathInterface |
joinAtomSequence(mixed<string> $atoms)
Joins a sequence of atoms to this path. |
|
PathInterface |
join(RelativePathInterface $path)
Joins the supplied path to this path. |
|
PathInterface |
joinTrailingSlash()
Adds a trailing slash to this path. |
|
PathInterface |
joinExtensions($extension)
Joins one or more extensions to this path. |
|
PathInterface |
joinExtensionSequence(mixed<string> $extensions)
Joins a sequence of extensions to this path. |
|
PathInterface |
suffixName(string $suffix)
Suffixes this path's name with a supplied string. |
|
PathInterface |
prefixName(string $prefix)
Prefixes this path's name with a supplied string. |
|
PathInterface |
replace(integer $index, mixed<string> $replacement, integer|null $length = null)
Replace a section of this path with the supplied atom sequence. |
|
PathInterface |
replaceName(string $name)
Replace this path's name. |
|
PathInterface |
replaceNameWithoutExtension(string $nameWithoutExtension)
Replace this path's name, but keep the last extension. |
|
PathInterface |
replaceNamePrefix(string $namePrefix)
Replace this path's name, but keep any extensions. |
|
PathInterface |
replaceNameSuffix(string|null $nameSuffix)
Replace all of this path's extensions. |
|
PathInterface |
replaceExtension(string|null $extension)
Replace this path's last extension. |
|
PathInterface |
replaceNameAtoms(integer $index, mixed<string> $replacement, integer|null $length = null)
Replace a section of this path's name with the supplied name atom sequence. |
|
PathInterface |
normalize()
Normalize this path to its most canonical form. |
Details
at line 47
public
__construct(mixed<string> $atoms, boolean|null $hasTrailingSeparator = null)
Construct a new path instance.
at line 66
public array<integer,string>
atoms()
Get the atoms of this path.
For example, the path '/foo/bar' has the atoms 'foo' and 'bar'.
at line 79
public string
atomAt(integer $index)
Get a single path atom by index.
at line 98
public mixed
atomAtDefault(integer $index, mixed $default = null)
Get a single path atom by index, falling back to a default if the index is undefined.
at line 120
public array<integer,string>
sliceAtoms(integer $index, integer|null $length = null)
Get a subset of the atoms of this path.
at line 135
public boolean
hasAtoms()
Determine if this path has any atoms.
at line 145
public boolean
hasTrailingSeparator()
Determine if this path has a trailing separator.
at line 155
public string
string()
Generate a string representation of this path.
at line 167
public string
__toString()
Generate a string representation of this path.
at line 177
public string
name()
Get this path's name.
at line 196
public array<integer,string>
nameAtoms()
Get this path's name atoms.
For example, the path name 'foo.bar' has the atoms 'foo' and 'bar'.
at line 209
public string
nameAtomAt(integer $index)
Get a single path name atom by index.
at line 228
public mixed
nameAtomAtDefault(integer $index, mixed $default = null)
Get a single path name atom by index, falling back to a default if the index is undefined.
at line 250
public array<integer,string>
sliceNameAtoms(integer $index, integer|null $length = null)
Get a subset of this path's name atoms.
at line 265
public string
nameWithoutExtension()
Get this path's name, excluding the last extension.
at line 282
public string
namePrefix()
Get this path's name, excluding all extensions.
at line 294
public string|null
nameSuffix()
Get all of this path's extensions.
at line 311
public string|null
extension()
Get this path's last extension.
at line 328
public boolean
hasExtension()
Determine if this path has any extensions.
at line 341
public boolean
contains(string $needle, boolean|null $caseSensitive = null)
Determine if this path contains a substring.
at line 365
public boolean
startsWith(string $needle, boolean|null $caseSensitive = null)
Determine if this path starts with a substring.
at line 389
public boolean
endsWith(string $needle, boolean|null $caseSensitive = null)
Determine if this path ends with a substring.
at line 416
public boolean
matches(string $pattern, boolean|null $caseSensitive = null, integer|null $flags = null)
Determine if this path matches a wildcard pattern.
at line 441
public boolean
matchesRegex(string $pattern, array $matches = null, integer|null $flags = null, integer|null $offset = null)
Determine if this path matches a regular expression.
at line 471
public boolean
nameContains(string $needle, boolean|null $caseSensitive = null)
Determine if this path's name contains a substring.
at line 495
public boolean
nameStartsWith(string $needle, boolean|null $caseSensitive = null)
Determine if this path's name starts with a substring.
at line 520
public boolean
nameMatches(string $pattern, boolean|null $caseSensitive = null, integer|null $flags = null)
Determine if this path's name matches a wildcard pattern.
at line 545
public boolean
nameMatchesRegex(string $pattern, array $matches = null, integer|null $flags = null, integer|null $offset = null)
Determine if this path's name matches a regular expression.
at line 574
public PathInterface
parent(integer|null $numLevels = null)
Get the parent of this path a specified number of levels up.
at line 595
public PathInterface
stripTrailingSlash()
Strips the trailing slash from this path.
at line 613
public PathInterface
stripExtension()
Strips the last extension from this path.
at line 623
public PathInterface
stripNameSuffix()
Strips all extensions from this path.
at line 637
public PathInterface
joinAtoms($atom)
Joins one or more atoms to this path.
at line 650
public PathInterface
joinAtomSequence(mixed<string> $atoms)
Joins a sequence of atoms to this path.
at line 670
public PathInterface
join(RelativePathInterface $path)
Joins the supplied path to this path.
at line 680
public PathInterface
joinTrailingSlash()
Adds a trailing slash to this path.
at line 702
public PathInterface
joinExtensions($extension)
Joins one or more extensions to this path.
at line 715
public PathInterface
joinExtensionSequence(mixed<string> $extensions)
Joins a sequence of extensions to this path.
at line 742
public PathInterface
suffixName(string $suffix)
Suffixes this path's name with a supplied string.
at line 760
public PathInterface
prefixName(string $prefix)
Prefixes this path's name with a supplied string.
at line 779
public PathInterface
replace(integer $index, mixed<string> $replacement, integer|null $length = null)
Replace a section of this path with the supplied atom sequence.
at line 806
public PathInterface
replaceName(string $name)
Replace this path's name.
at line 835
public PathInterface
replaceNameWithoutExtension(string $nameWithoutExtension)
Replace this path's name, but keep the last extension.
at line 854
public PathInterface
replaceNamePrefix(string $namePrefix)
Replace this path's name, but keep any extensions.
at line 866
public PathInterface
replaceNameSuffix(string|null $nameSuffix)
Replace all of this path's extensions.
at line 898
public PathInterface
replaceExtension(string|null $extension)
Replace this path's last extension.
at line 938
public PathInterface
replaceNameAtoms(integer $index, mixed<string> $replacement, integer|null $length = null)
Replace a section of this path's name with the supplied name atom sequence.
at line 959
public PathInterface
normalize()
Normalize this path to its most canonical form.