function Response::getHeader
Same name in this branch
- 11.1.x vendor/composer/composer/src/Composer/Util/Http/Response.php \Composer\Util\Http\Response::getHeader()
Return value
string|array|null The first header value if $first is true, an array of values otherwise
File
-
vendor/
symfony/ browser-kit/ Response.php, line 75
Class
- Response
- @author Fabien Potencier <fabien@symfony.com>
Namespace
Symfony\Component\BrowserKitCode
public function getHeader(string $header, bool $first = true) : string|array|null {
$normalizedHeader = str_replace('-', '_', strtolower($header));
foreach ($this->headers as $key => $value) {
if (str_replace('-', '_', strtolower($key)) === $normalizedHeader) {
if ($first) {
return \is_array($value) ? \count($value) ? $value[0] : '' : $value;
}
return \is_array($value) ? $value : [
$value,
];
}
}
return $first ? null : [];
}