W3cubDocs

/Symfony 2.7

Symfony\Component\PropertyAccess\PropertyPath

class PropertyPath implements IteratorAggregate, PropertyPathInterface

Default implementation of {@link PropertyPathInterface}.

Constants

SINGULAR_SEPARATOR

Character used for separating between plural and singular of an element.

Methods

__construct(PropertyPath|string $propertyPath)

Constructs a property path from a string.

string __toString()

Returns the string representation of the property path

int getLength()

Returns the length of the property path, i.e.

PropertyPath getParent()

Returns the parent property path.

PropertyPathIteratorInterface getIterator()

Returns a new iterator for this path

array getElements()

Returns the elements of the property path as array

string getElement(int $index)

Returns the element at the given index in the property path

bool isProperty(int $index)

Returns whether the element at the given index is a property

bool isIndex(int $index)

Returns whether the element at the given index is an array index

Details

public __construct(PropertyPath|string $propertyPath)

Constructs a property path from a string.

Parameters

PropertyPath|string $propertyPath The property path as string or instance

Exceptions

UnexpectedTypeException If the given path is not a string
InvalidPropertyPathException If the syntax of the property path is not valid

public string __toString()

Returns the string representation of the property path

Return Value

string The path as string

public int getLength()

Returns the length of the property path, i.e.

the number of elements.

Return Value

int The path length

public PropertyPath getParent()

Returns the parent property path.

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 Value

PropertyPath The parent path or null

public PropertyPathIteratorInterface getIterator()

Returns a new iterator for this path

public array getElements()

Returns the elements of the property path as array

Return Value

array An array of property/index names

public string getElement(int $index)

Returns the element at the given index in the property path

Parameters

int $index The index key

Return Value

string A property or index name

Exceptions

OutOfBoundsException If the offset is invalid

public bool isProperty(int $index)

Returns whether the element at the given index is a property

Parameters

int $index The index in the property path

Return Value

bool Whether the element at this index is a property

Exceptions

OutOfBoundsException If the offset is invalid

public bool isIndex(int $index)

Returns whether the element at the given index is an array index

Parameters

int $index The index in the property path

Return Value

bool Whether the element at this index is an array index

Exceptions

OutOfBoundsException If the offset is invalid

© 2004–2016 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/2.7/Symfony/Component/PropertyAccess/PropertyPath.html