Exemplo n.º 1
0
 /**
  * Sets $element as $pos child, overwrites existent if any
  *
  * @param DataTreeBase $element
  * @throws \InvalidArgumentException
  */
 protected function setChild(DataTreeBase $element, $pos)
 {
     if (!is_int($pos) || $pos < 0) {
         throw new \InvalidArgumentException('Pos have to be a positive integer');
     } elseif ($this->getValue()) {
         throw new \InvalidArgumentException('Cannot set a child if tree is a leaf one');
     } else {
         $element->setParent($this);
         $this->elements[$pos] = $element;
     }
 }