| Conditions | 3 |
| Paths | 3 |
| Total Lines | 25 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 28 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
||
| 29 | { |
||
| 30 | $response = $handler->handle($request); |
||
| 31 | |||
| 32 | if (!$this->containsHtml($response)) { |
||
| 33 | return $response; |
||
| 34 | } |
||
| 35 | |||
| 36 | $htmlSource = $response->getBody() |
||
| 37 | ->getContents(); |
||
| 38 | |||
| 39 | if ('' === $htmlSource) { |
||
| 40 | return $response; |
||
| 41 | } |
||
| 42 | |||
| 43 | $htmlMinified = $this->getAdapter() |
||
| 44 | ->minify($htmlSource); |
||
| 45 | |||
| 46 | [$in, $out, $diff] = $this->getSuffixStatistics($htmlSource, $htmlMinified); |
||
| 47 | |||
| 48 | $htmlMinified .= PHP_EOL . sprintf(self::HTML_SUFFIX, $in, $out, $diff); |
||
| 49 | |||
| 50 | $body = Factory::getStreamFactory()->createStream($htmlMinified); |
||
| 51 | |||
| 52 | return $response->withBody($body); |
||
| 53 | } |
||
| 55 |