Skip to content

Commit

Permalink
Improve code readability
Browse files Browse the repository at this point in the history
  • Loading branch information
tigrang committed Aug 10, 2013
1 parent 777a46f commit f6e1c7c
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions lib/Cake/Network/CakeResponse.php
Expand Up @@ -565,17 +565,15 @@ public function header($header = null, $value = null) {
if (is_null($header)) {
return $this->_headers;
}
if (!is_array($header)) {
$header = array($header => $value);
}
foreach ($header as $h => $v) {
if (is_numeric($h)) {
list($h, $v) = array($v, null);
$headers = is_array($header) ? $header : array($header => $value);
foreach ($headers as $header => $value) {
if (is_numeric($header)) {
list($header, $value) = array($value, null);
}
if (is_null($v)) {
list($h, $v) = explode(':', $h, 2);
if (is_null($value)) {
list($header, $value) = explode(':', $header, 2);
}
$this->_headers[$h] = (is_array($v)) ? array_map('trim', $v) : trim($v);
$this->_headers[$header] = is_array($value) ? array_map('trim', $value) : trim($value);
}
return $this->_headers;
}
Expand Down

0 comments on commit f6e1c7c

Please sign in to comment.