Class ObjectPath
ObjectPath is a utility for parsing object and array strings into ObjectPathValues.
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
- $path
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
- $path
Returns
array
protected
array
getPropertyCollection( mixed $subject )
Returns a property as an array.
Returns a property as an array.
Parameters
- $subject
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
- $key
Returns
mixed