public static function map($object, $apiclass, $type, $options = null)
{
if ($object instanceof \Zend_Date || $object instanceof \DateTimeInterface) {
$object = $object->getTimestamp();
} elseif (is_object($object)) {
if (Tool::classExists($apiclass)) {
$new = new $apiclass();
if (method_exists($new, "map")) {
$new->map($object, $options);
$object = $new;
}
} else {
throw new \Exception("Webservice\\Data\\Mapper: Cannot map [ {$apiclass} ] - class does not exist");
}
} elseif (is_array($object)) {
$tmpArray = [];
foreach ($object as $v) {
$className = self::findWebserviceClass($v, $type);
$tmpArray[] = self::map($v, $className, $type);
}
$object = $tmpArray;
}
return $object;
}