| Conditions | 4 |
| Paths | 3 |
| Total Lines | 17 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 41 | public static function isXML($content) |
||
| 42 | { |
||
| 43 | $content = trim($content); |
||
| 44 | if (empty($content)) { |
||
| 45 | return false; |
||
| 46 | } |
||
| 47 | if (stripos($content, '<!DOCTYPE html>') !== false |
||
| 48 | || stripos($content, '</html>') !== false |
||
| 49 | ) { |
||
| 50 | return false; |
||
| 51 | } |
||
| 52 | libxml_use_internal_errors(true); |
||
| 53 | libxml_clear_errors(); |
||
| 54 | simplexml_load_string($content, \SimpleXMLElement::class, LIBXML_NOCDATA); |
||
| 55 | $errors = libxml_get_errors(); |
||
| 56 | libxml_clear_errors(); |
||
| 57 | return empty($errors); |
||
| 58 | } |
||
| 59 | } |