import('Realdom.Disjunction', true); /** * Class \Hoa\Praspel\Model\Specification. * * Represent a specification (contains all clauses). * * @copyright Copyright © 2007-2015 Hoa community * @license New BSD License */ class Specification extends Behavior { /** * Name. * * @const string */ const NAME = ''; /** * Allowed clauses. * * @var array */ protected static $_allowedClauses = [ 'is', 'invariant', 'requires', 'behavior', 'default', 'ensures', 'throwable', 'description' ]; /** * Implicit variables. * * @var array */ protected $_implicitVariables = []; /** * Binded class. * * @var string */ protected $_bindedClass = null; /** * Cancel the constructor from the parent. * * @return void */ public function __construct() { return; } /** * Get an implicit variable. * * @param string $identifier Identifier. * @return \Hoa\Praspel\Model\Variable\Implicit */ public function getImplicitVariable($identifier) { if (isset($this->_implicitVariables[$identifier])) { return $this->_implicitVariables[$identifier]; } return $this->_implicitVariables[$identifier] = new Variable\Implicit($identifier, false, $this); } /** * Bind this specification to a specific class. * Obligatory for dynamic or static resolutions. * * @return string */ public function bindToClass($classname) { $old = $this->_bindedClass; $this->_bindedClass = ltrim($classname, '\\'); return $old; } /** * Get binded class. * * @return string */ public function getBindedClass() { return $this->_bindedClass; } /** * Get identifier (fallback). * * @return string */ protected function _getId() { return 'praspel'; } }