Exemplo n.º 1
0
 /**
  * Get identifier object.
  *
  * @param   string  $identifier    Identifier.
  * @return  \Hoa\Praspel\Model\Variable
  */
 public function getIdentifier($identifier)
 {
     if (!isset($this->_clause[$identifier])) {
         throw new Praspel\Exception\Interpreter('The identifier %s does not exist on clause %s.', 3, [$identifier, $this->_clause->getName()]);
     }
     return $this->_clause[$identifier];
 }
Exemplo n.º 2
0
 /**
  * Build a variable.
  *
  * @param   string                     $name      Name.
  * @param   bool                       $local     Local.
  * @param   \Hoa\Praspel\Model\Clause  $clause    Clause.
  * @return  void
  * @throws  \Hoa\Praspel\Exception\Model
  */
 public function __construct($name, $local, Praspel\Model\Clause $clause = null)
 {
     if (('\\old' === substr($name, 0, 4) || '\\result' === $name) && !$clause instanceof Praspel\Model\Ensures) {
         throw new Praspel\Exception\Model('\\old(…) and \\result are only allowed in @ensures, ' . 'given %s in @%s.', 0, [$name, $clause->getName()]);
     }
     $this->_name = $name;
     $this->_local = $local;
     $this->_clause = $clause;
     $this->_refDomains =& $this->_domains;
     return;
 }
Exemplo n.º 3
0
 /**
  * Add a clause.
  *
  * @param   \Hoa\Praspel\Model\Clause  $clause    Clause.
  * @return  \Hoa\Praspel\Model\Clause
  */
 public function addClause(Clause $clause)
 {
     $name = $clause->getName();
     if (false === in_array($name, static::getAllowedClauses())) {
         throw new Praspel\Exception\Model('Clause @%s is not allowed in @%s.', 7, [$name, $this->getId()]);
     }
     $clause->setParent($this);
     return $this->_clauses[$name] = $clause;
 }