public function replaceWith($content) { $this->apply($this->_nodes, $content, function ($targetNode, $contentNodes) { return $this->modify($targetNode)->insertNodesBefore($contentNodes); }); $this->remove(); return $this; }