Conditions | 3 |
Paths | 3 |
Total Lines | 28 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 3.0052 |
Changes | 0 |
1 | <?php |
||
12 | 7 | public static function htmlXPath(\DOMDocument &$DOMDocument, $html, $xpathQuery) |
|
13 | { |
||
14 | 7 | $html = self::normalizeHTML($html); |
|
|
|||
15 | |||
16 | 7 | libxml_use_internal_errors(true); |
|
17 | |||
18 | 7 | $DOMDocument->loadHTML($html); |
|
19 | |||
20 | 7 | $xmlErrors = libxml_get_errors(); |
|
21 | |||
22 | /** @var \LibXMLError $error */ |
||
23 | 7 | foreach ($xmlErrors as $error) |
|
24 | { |
||
25 | // http://www.xmlsoft.org/html/libxml-xmlerror.html#xmlParserErrors |
||
26 | 1 | if ($error->code === 801) |
|
27 | { |
||
28 | continue; |
||
29 | } |
||
30 | |||
31 | 1 | @trigger_error($error->message, E_USER_WARNING); |
|
32 | } |
||
33 | |||
34 | 7 | libxml_clear_errors(); |
|
35 | |||
36 | 7 | $xpath = new \DOMXPath($DOMDocument); |
|
37 | |||
38 | 7 | return $xpath->query($xpathQuery); |
|
39 | } |
||
40 | |||
51 |