src/Nodes/NodeTrait.php
public function hasSingleTagInsideElement($tag)
    {
        // There should be exactly 1 element child with given tag
        if (count($children = $this->getChildren(true)) !== 1 || $children[0]->nodeName !== $tag) {
            return false;
        }

        // And there should be no text nodes with real content
        return array_reduce($children, function ($carry, $child) {
            if (!$carry === false) {
                return false;
            }

            /* @var DOMNode $child */
            return !($child->nodeType === XML_TEXT_NODE && !preg_match('/\S$/', $child->getTextContent()));
        });
    }
public function hasSingleTagInsideElement($tag)
    {
        // There should be exactly 1 element child with given tag
        if (count($children = $this->getChildren(true)) !== 1 || $children[0]->nodeName !== $tag) {
            return false;
        }

        // And there should be no text nodes with real content
        return array_reduce($children, function ($carry, $child) {
            if (!$carry === false) {
                return false;
            }

            /* @var DOMNode $child */
            return !($child->nodeType === XML_TEXT_NODE && !preg_match('/\S$/', $child->getTextContent()));
        });
    }
public function hasSingleTagInsideElement ( $ tag ) { // There should be exactly 1 element child with given tag if ( count ( $ children = $ this -> getChildren ( true ) ) !== 1 || $ children [ 0 ] -> nodeName !== $ tag ) { return false ; } // And there should be no text nodes with real content return array_reduce ( $ children , function ( $ carry , $ child ) { if ( ! $ carry === false ) { return false ; } /* @var DOMNode $child */ return ! ( $ child -> nodeType === XML_TEXT_NODE && ! preg_match ( '/\S$/' , $ child -> getTextContent ( ) ) ) ; } ) ; }
Check if this node has only whitespace and a single element with given tag
or if it contains no element with given tag or more than 1 element.

@param $tag string Name of tag

@return bool
Check if this node has only whitespace and a single element with given tag or if it contains no element with given tag or more than 1 element .