trait InjectContentTypeTrait in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/zendframework/zend-diactoros/src/Response/InjectContentTypeTrait.php \Zend\Diactoros\Response\InjectContentTypeTrait
Hierarchy
- trait \Zend\Diactoros\Response\InjectContentTypeTrait
File
- vendor/
zendframework/ zend-diactoros/ src/ Response/ InjectContentTypeTrait.php, line 12
Namespace
Zend\Diactoros\ResponseView source
trait InjectContentTypeTrait {
/**
* Inject the provided Content-Type, if none is already present.
*
* @param string $contentType
* @param array $headers
* @return array Headers with injected Content-Type
*/
private function injectContentType($contentType, array $headers) {
$hasContentType = array_reduce(array_keys($headers), function ($carry, $item) {
return $carry ?: strtolower($item) === 'content-type';
}, false);
if (!$hasContentType) {
$headers['content-type'] = [
$contentType,
];
}
return $headers;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
InjectContentTypeTrait:: |
private | function | Inject the provided Content-Type, if none is already present. |