DiDom\Element::remove PHP Method

remove() public method

Removes child from list of children.
public remove ( ) : Element
return Element the node that has been removed
    public function remove()
    {
        if ($this->node->parentNode === null) {
            throw new LogicException('Can not remove element without parent node');
        }
        $node = $this->node->parentNode->removeChild($this->node);
        return new Element($node);
    }

Usage Example

示例#1
0
 /**
  * @expectedException LogicException
  */
 public function testRemoveWithoutParentNode()
 {
     $element = new Element('div', 'Foo');
     $element->remove();
 }