Conditions | 4 |
Paths | 6 |
Total Lines | 26 |
Lines | 4 |
Ratio | 15.38 % |
Changes | 0 |
1 | <?php |
||
27 | protected function doValidation(ResponseInterface $response) |
||
28 | { |
||
29 | $body = (string)$response->getBody(); |
||
30 | |||
31 | $dom = new \DOMDocument(); |
||
32 | @$dom->loadXML($body); |
||
|
|||
33 | |||
34 | $error = false; |
||
35 | $messageParts = array(); |
||
36 | |||
37 | foreach ($this->xsdFiles as $xsdFile) { |
||
38 | $valid = @$dom->schemaValidate($xsdFile['xsdfileurl']); |
||
39 | |||
40 | if (!$valid) { |
||
41 | $error = true; |
||
42 | $lastError = libxml_get_last_error(); |
||
43 | |||
44 | $messageParts[] = $xsdFile['xsdfilename'] . ' - ' . $xsdFile['xsdfileurl'] . ' (last error: ' . str_replace("\n", '', $lastError->message) . ').'; |
||
45 | } |
||
46 | } |
||
47 | |||
48 | View Code Duplication | if ($error === true) { |
|
49 | $message = 'XML file (' . (string)$response->getUri() . ') does not validate against the following XSD files: ' . implode(', ', $messageParts); |
||
50 | throw new ValidationFailedException($message); |
||
51 | } |
||
52 | } |
||
53 | } |
||
54 |
If you suppress an error, we recommend checking for the error condition explicitly: