GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

XsdValidator::validate()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 11
nc 3
nop 2
1
<?php
2
3
namespace Hautzi\SystemMailBundle\SystemMailer\XML;
4
5
class XsdValidator
6
{
7
    /**
8
     * @param string $xmlString
9
     * @param string $xsdFile
10
     *
11
     * @return bool
12
     *
13
     * @throws XsdValidationException when validation fails
14
     */
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