Access the field of a given object. This field has to be public directly or indirectly (through an accessor get* or a magic method, __get, __call).
is*() is not supported.
mixed
public static function getObjectFieldValue($object, $field) {
$accessor = "get" . $field;
if (method_exists($object, $accessor) || method_exists($object, '__call')) {
return $object
->{$accessor}();
}
if ($object instanceof \ArrayAccess) {
return $object[$field];
}
return $object->{$field};
}