private function sumUpWhitespace(HtmlDomParser $dom): HtmlDomParser
    {
        $text_nodes = $dom->find('//text()');
        foreach ($text_nodes as $text_node_wrapper) {
            /* @var $text_node \DOMNode */
            $text_node = $text_node_wrapper->getNode();
            $xp = $text_node->getNodePath();

            $doSkip = false;
            foreach (self::$skipTagsForRemoveWhitespace as $pattern) {
                if (\strpos($xp, "/${pattern}") !== false) {
                    $doSkip = true;

                    break;
                }
            }
            if ($doSkip) {
                continue;
            }

            $text_node->nodeValue = \preg_replace(self::$regExSpace, ' ', $text_node->nodeValue);
        }

        $dom->getDocument()->normalizeDocument();

        return $dom;
    }
private function sumUpWhitespace(HtmlDomParser $dom): HtmlDomParser
    {
        $text_nodes = $dom->find('//text()');
        foreach ($text_nodes as $text_node_wrapper) {
            /* @var $text_node \DOMNode */
            $text_node = $text_node_wrapper->getNode();
            $xp = $text_node->getNodePath();

            $doSkip = false;
            foreach (self::$skipTagsForRemoveWhitespace as $pattern) {
                if (\strpos($xp, "/${pattern}") !== false) {
                    $doSkip = true;

                    break;
                }
            }
            if ($doSkip) {
                continue;
            }

            $text_node->nodeValue = \preg_replace(self::$regExSpace, ' ', $text_node->nodeValue);
        }

        $dom->getDocument()->normalizeDocument();

        return $dom;
    }
private function sumUpWhitespace ( HtmlDomParser $ dom ) : HtmlDomParser { $ text_nodes = $ dom -> find ( '//text()' ) ; foreach ( $ text_nodes as $ text_node_wrapper ) { /* @var $text_node \DOMNode */ $ text_node = $ text_node_wrapper -> getNode ( ) ; $ xp = $ text_node -> getNodePath ( ) ; $ doSkip = false ; foreach ( self :: $ skipTagsForRemoveWhitespace as $ pattern ) { if ( \ strpos ( $ xp , "/${pattern}" ) !== false ) { $ doSkip = true ; break ; } } if ( $ doSkip ) { continue ; } $ text_node -> nodeValue = \ preg_replace ( self :: $ regExSpace , ' ' , $ text_node -> nodeValue ) ; } $ dom -> getDocument ( ) -> normalizeDocument ( ) ; return $ dom ; }
Sum-up extra whitespace from dom-nodes.

@param HtmlDomParser $dom

@return HtmlDomParser
Sum - up extra whitespace from dom - nodes .