public static function get($object, $path)
{
if (!is_array($object) && !is_object($object)) {
return $object;
}
$properties = explode('.', $path);
foreach ($properties as $prop) {
if (is_array($object) || $object instanceof \ArrayAccess) {
if (array_key_exists($prop, $object)) {
$object = $object[$prop];
} else {
throw new TInvalidPropertyException('sqlmap_invalid_property', $path);
}
} else {
if (is_object($object)) {
$getter = 'get' . $prop;
if (method_exists($object, $getter) && is_callable(array($object, $getter))) {
$object = $object->{$getter}();
} else {
if (in_array($prop, array_keys(get_object_vars($object)))) {
$object = $object->{$prop};
} elseif (method_exists($object, '__get') && is_callable(array($object, '__get'))) {
$object = $object->{$prop};
} else {
throw new TInvalidPropertyException('sqlmap_invalid_property', $path);
}
}
} else {
throw new TInvalidPropertyException('sqlmap_invalid_property', $path);
}
}
}
return $object;
}