public function to($format, array $options = array())
{
$defaults = array('handlers' => array());
$options += $defaults;
$options['handlers'] += $this->_handlers;
switch ($format) {
case 'array':
$data = $this->_updated;
$rel = array_map(function ($obj) {
return $obj->data();
}, $this->_relationships);
$data = $rel + $data;
$options['indexed'] = isset($options['indexed']) ? $options['indexed'] : false;
$result = Collection::toArray($data, $options);
break;
case 'string':
$result = $this->__toString();
break;
default:
$result = $this;
break;
}
return $result;
}