src/Node/AbstractParentNode.php 1 location
|
@@ 37-44 (lines=8) @@
|
| 34 |
|
* @param AbstractNode $node |
| 35 |
|
* @return void |
| 36 |
|
*/ |
| 37 |
|
protected function setParent(AbstractNode $node) |
| 38 |
|
{ |
| 39 |
|
if (null !== $this->reflectionProperty->getValue($node)) { |
| 40 |
|
throw new \InvalidArgumentException('Node already got a parent!'); |
| 41 |
|
} |
| 42 |
|
|
| 43 |
|
$this->reflectionProperty->setValue($node, $this); |
| 44 |
|
} |
| 45 |
|
} |
| 46 |
|
|
src/Node/ObjectNode.php 1 location
|
@@ 12-23 (lines=12) @@
|
| 9 |
|
* @param AbstractNode $node |
| 10 |
|
* @return $this |
| 11 |
|
*/ |
| 12 |
|
public function add($name, AbstractNode $node) |
| 13 |
|
{ |
| 14 |
|
if (null !== $this->reflectionProperty->getValue($node)) { |
| 15 |
|
throw new \InvalidArgumentException('Node already got a parent!'); |
| 16 |
|
} |
| 17 |
|
|
| 18 |
|
$this->setParent($node); |
| 19 |
|
|
| 20 |
|
$this->children[$name] = $node; |
| 21 |
|
|
| 22 |
|
return $this; |
| 23 |
|
} |
| 24 |
|
|
| 25 |
|
/** |
| 26 |
|
* @return \stdClass|null |