QueryPath\DOMQuery::wrapInner PHP Метод

wrapInner() публичный Метод

Markup is usually a string, but it can also be a DOMNode, a document fragment, a SimpleXMLElement, or another DOMNode object (in which case the first item in the list will be used.)
См. также: wrap()
См. также: wrapAll()
public wrapInner ( string $markup )
$markup string Markup that will wrap children of each element in the current list.
    public function wrapInner($markup)
    {
        $data = $this->prepareInsert($markup);
        // No data? Short circuit.
        if (empty($data)) {
            return $this;
        }
        foreach ($this->matches as $m) {
            if ($data instanceof \DOMDocumentFragment) {
                $wrapper = $data->firstChild->cloneNode(true);
            } else {
                $wrapper = $data->cloneNode(true);
            }
            if ($wrapper->hasChildNodes()) {
                $deepest = $this->deepestNode($wrapper);
                // FIXME: ???
                $bottom = $deepest[0];
            } else {
                $bottom = $wrapper;
            }
            if ($m->hasChildNodes()) {
                while ($m->firstChild) {
                    $kid = $m->removeChild($m->firstChild);
                    $bottom->appendChild($kid);
                }
            }
            $m->appendChild($wrapper);
        }
        return $this;
    }