/** * get html dom from string */ public static function fromString($str, $params = []) { $defaults = ['lowercase' => true, 'forceTagsClosed' => true, 'target_charset' => DEFAULT_TARGET_CHARSET, 'stripRN' => false, 'defaultBRText' => DEFAULT_BR_TEXT, 'defaultSpanText' => DEFAULT_SPAN_TEXT]; $settings = array_merge($defaults, $params); extract($settings); $dom = new DomDocument(['str' => null, 'lowercase' => $lowercase, 'forceTagsClosed' => $forceTagsClosed, 'target_charset' => $target_charset, 'stripRN' => $stripRN, 'defaultBRText' => $defaultBRText, 'defaultSpanText' => $defaultSpanText]); if (empty($str) || strlen($str) > MAX_FILE_SIZE) { $dom->clear(); return false; } $dom->load($str, $lowercase, $stripRN); return $dom; }