merged branch gatsu/patch-1 (PR #3689)
Commits
-------
b718960
HttpFoundation\HeaderBag Little improvement.
Discussion
----------
[HttpFoundation\HeaderBag] Removed unnecessary anonymous function
---------------------------------------------------------------------------
by vicb at 2012-03-24T16:07:00Z
Related issue: #3294
This commit is contained in:
commit
74b7bb3605
@ -50,16 +50,13 @@ class HeaderBag implements \IteratorAggregate, \Countable
|
||||
return '';
|
||||
}
|
||||
|
||||
$beautifier = function ($name) {
|
||||
return preg_replace_callback('/\-(.)/', function ($match) { return '-'.strtoupper($match[1]); }, ucfirst($name));
|
||||
};
|
||||
|
||||
$max = max(array_map('strlen', array_keys($this->headers))) + 1;
|
||||
$content = '';
|
||||
ksort($this->headers);
|
||||
foreach ($this->headers as $name => $values) {
|
||||
$name = implode('-', array_map('ucfirst', explode('-', $name)));
|
||||
foreach ($values as $value) {
|
||||
$content .= sprintf("%-{$max}s %s\r\n", $beautifier($name).':', $value);
|
||||
$content .= sprintf("%-{$max}s %s\r\n", $name.':', $value);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user