| Total Complexity | 4 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | final class SendHeadersMiddleware implements MiddlewareInterface |
||
| 27 | { |
||
| 28 | /** |
||
| 29 | * {@inheritdoc} |
||
| 30 | */ |
||
| 31 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
||
| 32 | { |
||
| 33 | \ob_start(); |
||
| 34 | |||
| 35 | $response = $handler->handle($request); |
||
| 36 | |||
| 37 | foreach ($response->getHeaders() as $header => $values) { |
||
| 38 | $name = $this->normalize($header); |
||
| 39 | |||
| 40 | foreach ($values as $value) { |
||
| 41 | \header( |
||
| 42 | \sprintf('%s: %s', $name, $value), |
||
| 43 | true, |
||
| 44 | $response->getStatusCode() |
||
| 45 | ); |
||
| 46 | } |
||
| 47 | } |
||
| 48 | |||
| 49 | \ob_get_flush(); |
||
| 50 | |||
| 51 | return $response; |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @param string $name |
||
| 56 | * |
||
| 57 | * @return string |
||
| 58 | */ |
||
| 59 | private function normalize(string $name): string |
||
| 65 | } |
||
| 66 | } |
||
| 67 |