Conditions | 3 |
Paths | 7 |
Total Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 3.0052 |
Changes | 0 |
1 | <?php |
||
36 | 16 | protected function validateSchema(\DOMDocument $doc) |
|
37 | { |
||
38 | try { |
||
39 | 16 | $element = $doc->firstChild; |
|
40 | 16 | if (!$element instanceof \DOMElement) { |
|
41 | // This is more for code completion. If the first child is not a DOMElement, PHP is probably broken |
||
42 | throw new \Exception('Invalid XML file'); |
||
43 | } |
||
44 | 16 | $schema = $this->configureSchema($element); |
|
45 | 16 | $out = $doc->saveXML(); |
|
46 | 16 | $validateDoc = new \DOMDocument(); |
|
47 | 16 | $validateDoc->loadXML($out); |
|
48 | 16 | $validateDoc->schemaValidate($schema); |
|
49 | 1 | } catch (\Exception $e) { |
|
50 | 1 | throw new InvalidFileStructureException(sprintf('Unable to load file %s due to exception: %s', $this->getFile(), $e->getMessage()), $e->getCode(), $e); |
|
51 | } |
||
52 | 15 | } |
|
53 | } |
||
54 |