function _serializeObject(&$object, $tagName = null, $attributes = array())
{
// check for magic function
if (method_exists($object, '__sleep')) {
$propNames = $object->__sleep();
if (is_array($propNames)) {
$properties = array();
foreach ($propNames as $propName) {
$properties[$propName] = $object->{$propName};
}
} else {
$properties = get_object_vars($object);
}
} else {
$properties = get_object_vars($object);
}
if (empty($tagName)) {
$tagName = get_class($object);
}
// typehints activated?
if ($this->options[XML_SERIALIZER_OPTION_TYPEHINTS] === true) {
$attributes[$this->options[XML_SERIALIZER_OPTION_ATTRIBUTE_TYPE]] = 'object';
$attributes[$this->options[XML_SERIALIZER_OPTION_ATTRIBUTE_CLASS]] = get_class($object);
}
$string = $this->_serializeArray($properties, $tagName, $attributes);
return $string;
}