| @@ 5-22 (lines=18) @@ | ||
| 2 | ||
| 3 | namespace Nayjest\Tree; | |
| 4 | ||
| 5 | class Node implements NodeInterface | |
| 6 | { | |
| 7 | use NodeTrait; | |
| 8 | ||
| 9 | /** | |
| 10 | * Node constructor. | |
| 11 | * @param ParentNodeInterface|null $parent | |
| 12 | * @param array|null $children | |
| 13 | */ | |
| 14 | public function __construct( | |
| 15 | ParentNodeInterface $parent = null, | |
| 16 | array $children = null | |
| 17 | ) | |
| 18 |     { | |
| 19 | ($children !== null) && $this->initializeCollection($children); | |
| 20 | $parent && $parent->children()->add($this); | |
| 21 | } | |
| 22 | } | |
| 23 | ||
| @@ 5-22 (lines=18) @@ | ||
| 2 | ||
| 3 | namespace Nayjest\Tree; | |
| 4 | ||
| 5 | class ReadonlyNode implements NodeInterface | |
| 6 | { | |
| 7 | use ReadonlyNodeTrait; | |
| 8 | ||
| 9 | /** | |
| 10 | * Node constructor. | |
| 11 | * @param ParentNodeInterface|null $parent | |
| 12 | * @param array|null $children | |
| 13 | */ | |
| 14 | public function __construct( | |
| 15 | ParentNodeInterface $parent = null, | |
| 16 | array $children = null | |
| 17 | ) | |
| 18 |     { | |
| 19 | ($children !== null) && $this->initializeCollection($children); | |
| 20 | $parent && $parent->children()->add($this); | |
| 21 | } | |
| 22 | } | |
| 23 | ||