Class ObjectPath
ObjectPath is a utility for parsing object and array strings into
ObjectPathValues.
Methods summary
public
|
|
public
Peridot\Leo\ObjectPath\ObjectPathValue
|
#
get( string $path )
Returns an ObjectPathValue if the property described by $path
can be located in the subject.
Returns an ObjectPathValue if the property described by $path
can be located in the subject.
A path expression uses object and array syntax.
Parameters
Returns
Code
$person = new stdClass();
$person->name = new stdClass();
$person->name->first = 'brian';
$person->name->last = 'scaturro';
$person->hobbies = ['programming', 'reading', 'board games'];
$path = new ObjectPath($person);
$first = $path->get('name->first');
$reading = $path->get('hobbies[0]');
Endcode
|
public
array
|
#
getPathParts( mixed $path )
Breaks a path expression into an array used
for navigating a path.
Breaks a path expression into an array used
for navigating a path.
Parameters
Returns
array
|
protected
array
|
#
getPropertyCollection( mixed $subject )
Returns a property as an array.
Returns a property as an array.
Parameters
Returns
array
|
protected
mixed
|
#
normalizeKey( mixed $key )
Return a key that can be used on the current subject.
Return a key that can be used on the current subject.
Parameters
Returns
mixed
|
Properties summary
protected
array|object
|
$subject
The subject to match path expressions against.
The subject to match path expressions against.
|
|