19 declare(strict_types=1);
36 public function isTrue(
string $string): bool
38 if (!preg_match(
'/<[^>]+?>/', $string)) {
42 $error_state = libxml_use_internal_errors(
true);
43 libxml_clear_errors();
46 set_error_handler(
static function (
int $severity,
string $message,
string $file,
int $line):
void {
47 throw new ErrorException($message, $severity, $severity, $file, $line);
51 $import_succeeded = $dom->loadHTML($string);
53 $errors = libxml_get_errors();
54 libxml_clear_errors();
55 libxml_use_internal_errors($error_state);
69 RecursiveIteratorIterator::SELF_FIRST
71 foreach ($iter as $element) {
73 if (strtolower($element->nodeName) ===
'body') {
77 if ($element->nodeType === XML_ELEMENT_NODE) {
84 $errors = libxml_get_errors();
85 libxml_clear_errors();
86 libxml_use_internal_errors($error_state);
89 restore_error_handler();