private function removeWhitespaceAroundTags(SimpleHtmlDom $element)
    {
        if (isset(self::$trimWhitespaceFromTags[$element->tag])) {
            $node = $element->getNode();

            /** @var \DOMNode[] $candidates */
            $candidates = [];
            if ($node->childNodes->length > 0) {
                $candidates[] = $node->firstChild;
                $candidates[] = $node->lastChild;
                $candidates[] = $node->previousSibling;
                $candidates[] = $node->nextSibling;
            }

            foreach ($candidates as &$candidate) {
                if ($candidate === null) {
                    continue;
                }

                if ($candidate->nodeType === \XML_TEXT_NODE) {
                    $candidate->nodeValue = \preg_replace(self::$regExSpace, ' ', $candidate->nodeValue);
                }
            }
        }
    }
private function removeWhitespaceAroundTags(SimpleHtmlDom $element)
    {
        if (isset(self::$trimWhitespaceFromTags[$element->tag])) {
            $node = $element->getNode();

            /** @var \DOMNode[] $candidates */
            $candidates = [];
            if ($node->childNodes->length > 0) {
                $candidates[] = $node->firstChild;
                $candidates[] = $node->lastChild;
                $candidates[] = $node->previousSibling;
                $candidates[] = $node->nextSibling;
            }

            foreach ($candidates as &$candidate) {
                if ($candidate === null) {
                    continue;
                }

                if ($candidate->nodeType === \XML_TEXT_NODE) {
                    $candidate->nodeValue = \preg_replace(self::$regExSpace, ' ', $candidate->nodeValue);
                }
            }
        }
    }
private function removeWhitespaceAroundTags ( SimpleHtmlDom $ element ) { if ( isset ( self :: $ trimWhitespaceFromTags [ $ element -> tag ] ) ) { $ node = $ element -> getNode ( ) ; /** @var \DOMNode[] $candidates */ $ candidates = [ ] ; if ( $ node -> childNodes -> length > 0 ) { $ candidates [ ] = $ node -> firstChild ; $ candidates [ ] = $ node -> lastChild ; $ candidates [ ] = $ node -> previousSibling ; $ candidates [ ] = $ node -> nextSibling ; } foreach ( $ candidates as & $ candidate ) { if ( $ candidate === null ) { continue ; } if ( $ candidate -> nodeType === \ XML_TEXT_NODE ) { $ candidate -> nodeValue = \ preg_replace ( self :: $ regExSpace , ' ' , $ candidate -> nodeValue ) ; } } } }
Trim tags in the dom.

@param SimpleHtmlDom $element

@return void
Trim tags in the dom .