FluentDOM\Element::offsetSet PHP Method

offsetSet() public method

public offsetSet ( integer | string $offset, DOMNode | string $value ) : DOMAttr | DOMNode | void
$offset integer | string
$value DOMNode | string
return DOMAttr | DOMNode | void
    public function offsetSet($offset, $value)
    {
        if (NULL === $offset || $this->isNodeOffset($offset)) {
            if (!$value instanceof \DOMNode) {
                throw new \InvalidArgumentException('$value is not a valid \\DOMNode');
            }
            if (NULL === $offset) {
                return $this->appendChild($value);
            } else {
                return $this->replaceChild($value, $this->childNodes->item((int) $offset));
            }
        } else {
            return $this->setAttribute($offset, (string) $value);
        }
    }