/** * @param $wrapper * * @return Element|Tag|Field */ public function wrap($wrapper) { $parent = $this->parentNode; $wrapper = $parent->appendChild($this->ownerDocument->check($wrapper)); $wrapper->appendChild($this->cloneNode(true)); $parent->replaceChild($wrapper, $this); return $wrapper; }
/** * @param null|string $sibling * * @return Element|Tag|Field */ public function before($sibling = null) { $prev = $this->previousSibling; if (is_null($sibling)) { if ($prev) { return $prev; } return $this; } return $this->parent()->insertBefore($this->ownerDocument->importNode($this->ownerDocument->check($sibling)), $this); }
/** * @param $element * * @return Element|Field|Tag */ public function before($element) { return $this->parent()->insertBefore($this->ownerDocument->importNode($this->ownerDocument->check($element)), $this); }