| Conditions | 7 |
| Paths | 4 |
| Total Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | public function validate(ResponseInterface $response) |
||
| 16 | { |
||
| 17 | if ($response instanceof ContentTypeAwareResponse) { |
||
| 18 | |||
| 19 | // @todo this could be part of the StandardRule class |
||
| 20 | $body = (string)$response->getBody(); |
||
| 21 | $body = preg_replace('/[\x00-\x09\x0B\x0C\x0E-\x1F\x7F,\xFF,\x8B]/', '', $body); |
||
| 22 | |||
| 23 | if (($response->getStatusCode() < 300 || $response->getStatusCode() >= 400) |
||
| 24 | && $response->getContentType() === 'text/html' |
||
| 25 | && strlen($body) > 0 |
||
| 26 | ) { |
||
| 27 | if (stripos($body, '</html>') === false) { |
||
| 28 | throw new ValidationFailedException('Closing html tag is missing (document length: ' . strlen($body) . ').'); |
||
| 29 | } |
||
| 30 | } |
||
| 31 | } |
||
| 32 | } |
||
| 33 | } |
||
| 34 |