Horde_Xml_Element::__set PHP Method

__set() public method

Map variable sets onto the underlying entry representation.
public __set ( string $var, string $val )
$var string The property to change.
$val string The property's new value.
    public function __set($var, $val)
    {
        if (!is_scalar($val)) {
            throw new InvalidArgumentException('Element values must be scalars, ' . gettype($val) . ' given');
        }
        $this->_ensureAppended();
        $nodes = $this->_children($var);
        if (!$nodes) {
            if (strpos($var, ':') !== false) {
                list($ns) = explode(':', $var, 2);
                $node = $this->_element->ownerDocument->createElementNS(Horde_Xml_Element::lookupNamespace($ns), $var, $val);
                $this->_element->appendChild($node);
            } else {
                $node = $this->_element->ownerDocument->createElement($var, $val);
                $this->_element->appendChild($node);
            }
            $this->_expireCachedChildren();
        } elseif (count($nodes) > 1) {
            throw new Horde_Xml_Element_Exception('Cannot set the value of multiple nodes simultaneously.');
        } else {
            $nodes[0]->nodeValue = $val;
        }
    }