Symfony\Component\PropertyAccess\PropertyAccessorInterface::getValue
Returns the value at the end of the property path of the object
Example: use Symfony\Component\PropertyAccess\PropertyAccess; $propertyAccessor = PropertyAccess::getPropertyAccessor(); echo $propertyAccessor->getValue($object, 'child.name); // equals echo $object->getChild()->getName(); This method first tries to find a public getter for each property in the path. The name of the getter must be the camel-cased property name prefixed with "get", "is", or "has". If the getter does not exist, this method tries to find a public property. The value of the property is then returned. If none of them are found, an exception is thrown.
Signature
public function getValue(object|array
$objectOrArray,
string|PropertyPathInterface
$propertyPath )
Parameters
$objectOrArray
— object- The object or array to traverse
$propertyPath
— object- The property path to read
Returns
- mixed
- The value at the end of the property path
Errors/Exceptions
-
NoSuchPropertyException
- If a property does not exist or is not public.