Get all headers as a collection
bool $asObjects Set to true to retrieve a collection of Header objects:
Collection Returns a {@see Collection} of all headers
Overrides MessageInterface::getHeaders
public function getHeaders($asObjects = false) {
if ($asObjects) {
$result = $this->headers;
}
else {
$result = array();
// Convert all of the headers into a collection
foreach ($this->headers as $header) {
foreach ($header
->raw() as $key => $value) {
$result[$key] = $value;
}
}
}
return new Collection($result);
}