'DateTime', 'timestamp' => $obj->getTimestamp()); } else { $newObj = static::marshall((array) $obj); $newObj[self::OBJ_TYPE] = get_class($obj); return $newObj; } } public static function unmarshall($obj) { switch (gettype($obj)) { case 'object': $obj = (array) $obj; case 'array': if (static::isWrappedObject($obj)) { return static::unwrapObject($obj); } else { return array_map(array('Marshaller','unmarshall'), $obj); } default: return $obj; } } private static function unwrapObject($obj) { $objectType = $obj[self::OBJ_TYPE]; unset($obj[self::OBJ_TYPE]); if ($objectType == 'DateTime') { $date = new DateTime(); $date->setTimestamp($obj['timestamp']); return $date; } else if (is_subclass_of($objectType, 'ResearchToolObjectInterface')) { return $objectType::create((object)static::unmarshall($obj)); } else { return $obj; } } } ?>