| Conditions | 8 |
| Paths | 5 |
| Total Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 8 |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | 10 | public function process(ServerRequestInterface $req, RequestHandlerInterface $handler): ResponseInterface |
|
| 22 | {
|
||
| 23 | 10 | $res = $handler->handle($req); |
|
| 24 | 10 | $code = $res->getStatusCode(); |
|
| 25 | |||
| 26 | 10 | if ($code >= 100 && $code < 200 || in_array($code, [204, 205, 304], true)) |
|
| 27 | {
|
||
| 28 | 6 | return $res; |
|
| 29 | } |
||
| 30 | |||
| 31 | 4 | if (! $res->hasHeader('Content-Type'))
|
|
| 32 | {
|
||
| 33 | 1 | $res = $res->withHeader('Content-Type', $this->contentType);
|
|
| 34 | } |
||
| 35 | |||
| 36 | 4 | if (! $res->hasHeader('Content-Length') && ! $res->hasHeader('Transfer-Encoding') && null !== ($size = $res->getBody()->getSize()))
|
|
| 37 | {
|
||
| 38 | 1 | $res = $res->withHeader('Content-Length', (string) $size);
|
|
| 39 | } |
||
| 40 | |||
| 41 | 4 | return $res; |
|
| 42 | } |
||
| 43 | } |