Hoa central
Constant.php
Go to the documentation of this file.
1 <?php
2 
38 
39 use Hoa\Praspel;
40 use Hoa\Realdom;
41 use Hoa\Visitor;
42 
51 class Constant
52  implements Realdom\IRealdom\Crate,
54 {
60  protected $_holder = null;
61 
67  protected $_praspelRepresentation = null;
68 
74  protected $_declaration = null;
75 
76 
77 
89  public function __construct(
90  Realdom\IRealdom\Holder $holder,
91  \Closure $praspel,
92  Praspel\Model\Declaration $declaration = null
93  ) {
94  $this->setHolder($holder);
95  $this->setPraspelRepresentation($praspel);
96  $this->setDeclaration($declaration);
97 
98  return;
99  }
100 
107  protected function setHolder(Realdom\IRealdom\Holder $holder)
108  {
109  $old = $this->_holder;
110  $this->_holder = $holder;
111 
112  return $old;
113  }
114 
120  public function getHolder()
121  {
122  return $this->_holder;
123  }
124 
131  public function getTypes()
132  {
133  $held = $this->getHolder()->getHeld();
134  $out = [];
135  $prefix = 'Hoa\Realdom\\';
136 
137  foreach ($held as $realdom) {
138  if ($realdom instanceof Realdom\RealdomArray) {
139  $out[] = $prefix . 'Constarray';
140  } elseif ($realdom instanceof Realdom\Boolean) {
141  $out[] = $prefix . 'Constboolean';
142  } elseif ($realdom instanceof Realdom\RealdomFloat) {
143  $out[] = $prefix . 'Constfloat';
144  } elseif ($realdom instanceof Realdom\Integer) {
145  $out[] = $prefix . 'Constinteger';
146  } elseif ($realdom instanceof Realdom\RealdomString) {
147  $out[] = $prefix . 'Conststring';
148  } else {
149  throw new Realdom\Exception(
150  'Cannot determine the type.',
151  0
152  );
153  }
154  }
155 
156  return $out;
157  }
158 
164  public function getConstantValue()
165  {
166  return $this->getHolder()->getValue();
167  }
168 
175  protected function setPraspelRepresentation(\Closure $praspel)
176  {
178  $this->_praspelRepresentation = $praspel;
179 
180  return $old;
181  }
182 
188  public function getPraspelRepresentation()
189  {
191  }
192 
199  public function setDeclaration(Praspel\Model\Declaration $declaration)
200  {
201  $old = $this->_declaration;
202  $this->_declaration = $declaration;
203 
204  return $old;
205  }
206 
212  public function getDeclaration()
213  {
214  return $this->_declaration;
215  }
216 
222  public function getConstantRepresentation()
223  {
224  return '';
225  }
226 
235  public function accept(
236  Visitor\Visit $visitor,
237  &$handle = null,
238  $eldnah = null
239  ) {
240  return $visitor->visit($this, $handle, $eldnah);
241  }
242 }
__construct(Realdom\IRealdom\Holder $holder,\Closure $praspel, Praspel\Model\Declaration $declaration=null)
Definition: Constant.php:89
setPraspelRepresentation(\Closure $praspel)
Definition: Constant.php:175
accept(Visitor\Visit $visitor, &$handle=null, $eldnah=null)
Definition: Constant.php:235
setHolder(Realdom\IRealdom\Holder $holder)
Definition: Constant.php:107
setDeclaration(Praspel\Model\Declaration $declaration)
Definition: Constant.php:199