Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
18 | public static function validate($xml, $schema) |
||
19 | { |
||
20 | libxml_use_internal_errors(true); |
||
21 | $xmlDocument = new \DOMDocument(); |
||
22 | $xmlDocument->loadXML($xml); |
||
23 | |||
24 | $schema = static::prepareSchema($schema); |
||
25 | |||
26 | if (!$xmlDocument->schemaValidateSource($schema)) { |
||
|
|||
27 | $errors = libxml_get_errors(); |
||
28 | |||
29 | foreach ($errors as $error) { |
||
30 | throw new \Exception(static::displayError($error)); |
||
31 | } |
||
32 | libxml_clear_errors(); |
||
33 | throw new \Exception('INVALID XML'); |
||
34 | } |
||
76 | } |