lithium\net\Message::to()
Converts the data in the record set to a different format, i.e. an array. Available options: array, url, context, or string.
Parameters
-
string
$format
Format to convert to.
-
array
$options
Returns
mixedSource
public function to($format, array $options = array()) {
switch ($format) {
case 'array':
$array = array();
$class = new ReflectionClass(get_class($this));
foreach ($class->getProperties(ReflectionProperty::IS_PUBLIC) as $prop) {
$array[$prop->getName()] = $prop->getValue($this);
}
return $array;
case 'url':
$host = $this->host . ($this->port ? ":{$this->port}" : '');
return "{$this->scheme}://{$host}{$this->path}";
case 'context':
$defaults = array('content' => $this->body(), 'ignore_errors' => true);
return array($this->scheme => $options + $defaults);
case 'string':
default:
return (string) $this;
}
}