public function wrapAll($content)
    {
        $content = self::create($content);
        $parent = $this->getNode(0)->parentNode;
        foreach ($this as $i => $node) {
            /** @var \DOMNode $node */
            if ($node->parentNode !== $parent) {
                throw new \LogicException('Nodes to be wrapped with wrapAll() must all have the same parent');
            }
        }

        $newnode = $content->getNode(0);
        /** @var \DOMNode $newnode */
        $newnode = static::importNewnode($newnode, $parent);

        $newnode = $parent->insertBefore($newnode,$this->getNode(0));
        $content->clear();
        $content->add($newnode);

        while ($newnode->hasChildNodes()) {
            $elementFound = false;
            foreach ($newnode->childNodes as $child) {
                if ($child instanceof \DOMElement) {
                    $newnode = $child;
                    $elementFound = true;
                    break;
                }
            }
            if (!$elementFound) {
                break;
            }
        }
        foreach ($this as $i => $node) {
            /** @var \DOMNode $node */
            $newnode->appendChild($node);
        }
        return $this;
    }
public function wrapAll($content)
    {
        $content = self::create($content);
        $parent = $this->getNode(0)->parentNode;
        foreach ($this as $i => $node) {
            /** @var \DOMNode $node */
            if ($node->parentNode !== $parent) {
                throw new \LogicException('Nodes to be wrapped with wrapAll() must all have the same parent');
            }
        }

        $newnode = $content->getNode(0);
        /** @var \DOMNode $newnode */
        $newnode = static::importNewnode($newnode, $parent);

        $newnode = $parent->insertBefore($newnode,$this->getNode(0));
        $content->clear();
        $content->add($newnode);

        while ($newnode->hasChildNodes()) {
            $elementFound = false;
            foreach ($newnode->childNodes as $child) {
                if ($child instanceof \DOMElement) {
                    $newnode = $child;
                    $elementFound = true;
                    break;
                }
            }
            if (!$elementFound) {
                break;
            }
        }
        foreach ($this as $i => $node) {
            /** @var \DOMNode $node */
            $newnode->appendChild($node);
        }
        return $this;
    }
public function wrapAll ( $ content ) { $ content = self :: create ( $ content ) ; $ parent = $ this -> getNode ( 0 ) -> parentNode ; foreach ( $ this as $ i => $ node ) { /** @var \DOMNode $node */ if ( $ node -> parentNode !== $ parent ) { throw new \ LogicException ( 'Nodes to be wrapped with wrapAll() must all have the same parent' ) ; } } $ newnode = $ content -> getNode ( 0 ) ; /** @var \DOMNode $newnode */ $ newnode = static :: importNewnode ( $ newnode , $ parent ) ; $ newnode = $ parent -> insertBefore ( $ newnode , $ this -> getNode ( 0 ) ) ; $ content -> clear ( ) ; $ content -> add ( $ newnode ) ; while ( $ newnode -> hasChildNodes ( ) ) { $ elementFound = false ; foreach ( $ newnode -> childNodes as $ child ) { if ( $ child instanceof \ DOMElement ) { $ newnode = $ child ; $ elementFound = true ; break ; } } if ( ! $ elementFound ) { break ; } } foreach ( $ this as $ i => $ node ) { /** @var \DOMNode $node */ $ newnode -> appendChild ( $ node ) ; } return $ this ; }
Wrap an HTML structure around all elements in the set of matched elements.

@param string|HtmlPageCrawler|\DOMNode|\DOMNodeList $content
@throws \LogicException
@return \Wa72\HtmlPageDom\HtmlPageCrawler $this for chaining
@api
Wrap an HTML structure around all elements in the set of matched elements .