private static function insertEllipsis($domNode, $ellipsis)
    {
        $avoid = array('a', 'strong', 'em', 'h1', 'h2', 'h3', 'h4', 'h5'); //html tags to avoid appending the ellipsis to

        if ($domNode->parentNode->parentNode !== null && in_array($domNode->parentNode->nodeName, $avoid, true)) {
            // Append as text node to parent instead
            $textNode = new DOMText($ellipsis);

            if ($domNode->parentNode->parentNode->nextSibling) {
                $domNode->parentNode->parentNode->insertBefore($textNode, $domNode->parentNode->parentNode->nextSibling);
            } else {
                $domNode->parentNode->parentNode->appendChild($textNode);
            }

        } else {
            // Append to current node
            $domNode->nodeValue = rtrim($domNode->nodeValue) . $ellipsis;
        }
    }
private static function insertEllipsis($domNode, $ellipsis)
    {
        $avoid = array('a', 'strong', 'em', 'h1', 'h2', 'h3', 'h4', 'h5'); //html tags to avoid appending the ellipsis to

        if ($domNode->parentNode->parentNode !== null && in_array($domNode->parentNode->nodeName, $avoid, true)) {
            // Append as text node to parent instead
            $textNode = new DOMText($ellipsis);

            if ($domNode->parentNode->parentNode->nextSibling) {
                $domNode->parentNode->parentNode->insertBefore($textNode, $domNode->parentNode->parentNode->nextSibling);
            } else {
                $domNode->parentNode->parentNode->appendChild($textNode);
            }

        } else {
            // Append to current node
            $domNode->nodeValue = rtrim($domNode->nodeValue) . $ellipsis;
        }
    }
private static function insertEllipsis ( $ domNode , $ ellipsis ) { $ avoid = array ( 'a' , 'strong' , 'em' , 'h1' , 'h2' , 'h3' , 'h4' , 'h5' ) ; //html tags to avoid appending the ellipsis to if ( $ domNode -> parentNode -> parentNode !== null && in_array ( $ domNode -> parentNode -> nodeName , $ avoid , true ) ) { // Append as text node to parent instead $ textNode = new DOMText ( $ ellipsis ) ; if ( $ domNode -> parentNode -> parentNode -> nextSibling ) { $ domNode -> parentNode -> parentNode -> insertBefore ( $ textNode , $ domNode -> parentNode -> parentNode -> nextSibling ) ; } else { $ domNode -> parentNode -> parentNode -> appendChild ( $ textNode ) ; } } else { // Append to current node $ domNode -> nodeValue = rtrim ( $ domNode -> nodeValue ) . $ ellipsis ; } }
Inserts an ellipsis
@param  DOMNode|DOMElement $domNode  Element to insert after.
@param  string             $ellipsis Text used to suffix our document.
@return void
Inserts an ellipsis