Conditions | 3 |
Paths | 3 |
Total Lines | 19 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
15 | public function validate($xmlString, $xsdFile) |
||
16 | { |
||
17 | libxml_use_internal_errors(true); |
||
18 | |||
19 | $xml = new \DOMDocument(); |
||
20 | $xml->loadXML($xmlString); |
||
21 | |||
22 | if (!$xml->schemaValidate($xsdFile)) { |
||
23 | $messages = []; |
||
24 | foreach (libxml_get_errors() as $error) { |
||
25 | array_push($messages, sprintf('%s in line %d', $error->message, $error->line)); |
||
26 | } |
||
27 | libxml_clear_errors(); |
||
28 | |||
29 | throw new XsdValidationException(implode(PHP_EOL, $messages)); |
||
30 | } |
||
31 | |||
32 | return true; |
||
33 | } |
||
34 | } |
||
35 |