Hoa central
Tree.php
Go to the documentation of this file.
1 <?php
2 
37 namespace Hoa\Tree;
38 
39 use Hoa\Core;
40 
49 class Tree extends Generic
50 {
59  public function insert(Generic $child)
60  {
61  if (!($child instanceof self)) {
62  throw new Exception(
63  'Child must be an instance of \Hoa\Tree; given %s.',
64  0,
65  get_class($child)
66  );
67  }
68 
69  $this->_childs[$child->getValue()->getId()] = $child;
70 
71  return $this;
72  }
73 
81  public function delete($nodeId)
82  {
83  unset($this->_childs[$nodeId]);
84 
85  return $this;
86  }
87 
93  public function isLeaf()
94  {
95  return empty($this->_childs);
96  }
97 
103  public function isNode()
104  {
105  return !empty($this->_childs);
106  }
107 }
108 
112 Core\Consistency::flexEntity('Hoa\Tree\Tree');
insert(Generic $child)
Definition: Tree.php:59