PropertyPath
in package
implements
IteratorAggregate, PropertyPathInterface
Default implementation of {@link PropertyPathInterface}.
Tags
Table of Contents
Interfaces
- IteratorAggregate
- PropertyPathInterface
- A sequence of property names or array indices.
Constants
- SINGULAR_SEPARATOR = '|'
- Character used for separating between plural and singular of an element.
Properties
- $elements : array<int, string>
- The elements of the property path.
- $isIndex : array<string|int, bool>
- Contains a Boolean for each property in $elements denoting whether this element is an index. It is a property otherwise.
- $isNullSafe : array<string|int, bool>
- Contains a Boolean for each property in $elements denoting whether this element is optional or not.
- $length : int
- The number of elements in the property path.
- $pathAsString : string
- String representation of the path.
Methods
- __construct() : mixed
- Constructs a property path from a string.
- __toString() : string
- Returns the string representation of the property path.
- getElement() : string
- Returns the element at the given index in the property path.
- getElements() : array<int, string>
- Returns the elements of the property path as array.
- getIterator() : PropertyPathIteratorInterface
- Returns a new iterator for this path.
- getLength() : int
- Returns the length of the property path, i.e. the number of elements.
- getParent() : PropertyPathInterface|null
- Returns the parent property path.
- isIndex() : bool
- Returns whether the element at the given index is an array index.
- isNullSafe() : bool
- Returns whether the element at the given index is null safe.
- isProperty() : bool
- Returns whether the element at the given index is a property.
Constants
SINGULAR_SEPARATOR
Character used for separating between plural and singular of an element.
public
mixed
SINGULAR_SEPARATOR
= '|'
Properties
$elements
The elements of the property path.
private
array<int, string>
$elements
= []
$isIndex
Contains a Boolean for each property in $elements denoting whether this element is an index. It is a property otherwise.
private
array<string|int, bool>
$isIndex
= []
$isNullSafe
Contains a Boolean for each property in $elements denoting whether this element is optional or not.
private
array<string|int, bool>
$isNullSafe
= []
$length
The number of elements in the property path.
private
int
$length
$pathAsString
String representation of the path.
private
string
$pathAsString
Methods
__construct()
Constructs a property path from a string.
public
__construct(self|string $propertyPath) : mixed
Parameters
- $propertyPath : self|string
Tags
__toString()
Returns the string representation of the property path.
public
__toString() : string
Return values
stringgetElement()
Returns the element at the given index in the property path.
public
getElement(int $index) : string
Parameters
- $index : int
-
The index key
Return values
stringgetElements()
Returns the elements of the property path as array.
public
getElements() : array<int, string>
Return values
array<int, string>getIterator()
Returns a new iterator for this path.
public
getIterator() : PropertyPathIteratorInterface
Return values
PropertyPathIteratorInterfacegetLength()
Returns the length of the property path, i.e. the number of elements.
public
getLength() : int
Return values
intgetParent()
Returns the parent property path.
public
getParent() : PropertyPathInterface|null
The parent property path is the one that contains the same items as this one except for the last one.
If this property path only contains one item, null is returned.
Return values
PropertyPathInterface|nullisIndex()
Returns whether the element at the given index is an array index.
public
isIndex(int $index) : bool
Parameters
- $index : int
-
The index in the property path
Return values
boolisNullSafe()
Returns whether the element at the given index is null safe.
public
isNullSafe(int $index) : bool
Parameters
- $index : int
Return values
boolisProperty()
Returns whether the element at the given index is a property.
public
isProperty(int $index) : bool
Parameters
- $index : int
-
The index in the property path