Total Complexity | 4 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Coverage | 37.5% |
Changes | 5 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
26 | final class SendHeadersMiddleware implements MiddlewareInterface |
||
27 | { |
||
28 | /** |
||
29 | * {@inheritdoc} |
||
30 | */ |
||
31 | 1 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
|
32 | { |
||
33 | 1 | \ob_start(); |
|
34 | |||
35 | 1 | $response = $handler->handle($request); |
|
36 | |||
37 | 1 | 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 | 1 | \ob_get_flush(); |
|
50 | |||
51 | 1 | return $response; |
|
52 | } |
||
53 | |||
54 | /** |
||
55 | * @param string $name |
||
56 | * |
||
57 | * @return string |
||
58 | */ |
||
59 | private function normalize(string $name): string |
||
65 | } |
||
66 | } |
||
67 |