Hoa central
Clause.php
Go to the documentation of this file.
1 <?php
2 
37 namespace Hoa\Praspel\Model;
38 
39 use Hoa\Visitor;
40 
49 abstract class Clause implements Visitor\Element
50 {
56  // const NAME = …;
57 
63  protected $_parent = null;
64 
65 
66 
73  public function __construct(Clause $parent)
74  {
75  $this->setParent($parent);
76 
77  return;
78  }
79 
86  protected function setParent(Clause $parent)
87  {
88  $old = $this->_parent;
89  $this->_parent = $parent;
90 
91  return $old;
92  }
93 
99  public function getParent()
100  {
101  return $this->_parent;
102  }
103 
109  public function getRoot()
110  {
111  $parent = $this;
112 
113  while (null !== $nextParent = $parent->getParent()) {
114  $parent = $nextParent;
115  }
116 
117  return $parent;
118  }
119 
125  public function getName()
126  {
127  return static::NAME;
128  }
129 
135  public function getId()
136  {
137  $out = null;
138  $parent = $this->getParent();
139 
140  if (null !== $parent &&
141  !($parent instanceof Specification)) {
142  $out .= $this->getParent()->getId() . '_';
143  }
144 
145  return $out . $this->_getId();
146  }
147 
153  protected function _getId()
154  {
155  return $this->getName();
156  }
157 
166  public function accept(
167  Visitor\Visit $visitor,
168  &$handle = null,
169  $eldnah = null
170  ) {
171  return $visitor->visit($this, $handle, $eldnah);
172  }
173 }
__construct(Clause $parent)
Definition: Clause.php:73
setParent(Clause $parent)
Definition: Clause.php:86
accept(Visitor\Visit $visitor, &$handle=null, $eldnah=null)
Definition: Clause.php:166