/** * @param string $key * @param AbstractNode $node * @param bool $allowDefault * * @return $this * * @throws \InvalidArgumentException */ public function add($key, AbstractNode $node, $allowDefault = false) { if (isset($this->children[$key])) { throw new \InvalidArgumentException(sprintf('There is already a node with key %s!', $key)); } $node->setParent($this); $this->children[$key] = new NodeChildRelation($node, $allowDefault); return $this; }
/** * @param AbstractNode $node * @param bool $allowDefault * * @return $this * * @throws \InvalidArgumentException */ public function add(AbstractNode $node, $allowDefault = false) { $node->setParent($this); $this->children[] = new NodeChildRelation($node, $allowDefault); return $this; }