aboutsummaryrefslogtreecommitdiffstats
path: root/Model/Specification.php
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2013-06-10 14:17:22 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2013-06-10 14:20:55 +0200
commit95d8e9a76566f980fb7e08fb7c27b6b884d53f57 (patch)
tree10f88f78936fb40395f7d9c5fbc77ee9071a2744 /Model/Specification.php
parent824e66a0399b20931678e1fdea2ce5fa018f6319 (diff)
downloadPraspel-95d8e9a76566f980fb7e08fb7c27b6b884d53f57.zip
Praspel-95d8e9a76566f980fb7e08fb7c27b6b884d53f57.tar.gz
Praspel-95d8e9a76566f980fb7e08fb7c27b6b884d53f57.tar.bz2
Add the allowedClauses attributes.
It helps to simplify the code.
Diffstat (limited to 'Model/Specification.php')
-rw-r--r--Model/Specification.php87
1 files changed, 15 insertions, 72 deletions
diff --git a/Model/Specification.php b/Model/Specification.php
index b5ac837..c731e75 100644
--- a/Model/Specification.php
+++ b/Model/Specification.php
@@ -44,16 +44,6 @@ from('Hoa')
-> import('Praspel.Model.Behavior')
/**
- * \Hoa\Praspel\Model\Is
- */
--> import('Praspel.Model.Is')
-
-/**
- * \Hoa\Praspel\Model\Description
- */
--> import('Praspel.Model.Description')
-
-/**
* \Hoa\Realdom\Disjunction
*/
-> import('Realdom.Disjunction', true);
@@ -81,6 +71,21 @@ class Specification extends Behavior {
*/
const NAME = '';
+ /**
+ * Allowed clauses.
+ *
+ * @var \Hoa\Praspel\Model\Specification array
+ */
+ protected static $_allowedClauses = array(
+ 'is',
+ 'requires',
+ 'ensures',
+ 'throwable',
+ 'invariant',
+ 'behavior',
+ 'description'
+ );
+
/**
@@ -95,68 +100,6 @@ class Specification extends Behavior {
}
/**
- * Get a specific clause.
- *
- * @access public
- * @param string $clause Clause (without leading arobase).
- * @return \Hoa\Praspel\Model\Clause
- * @throw \Hoa\Praspel\Exception\Model
- */
- public function getClause ( $clause ) {
-
- if(isset($this->_clauses[$clause]))
- return $this->_clauses[$clause];
-
- $handle = null;
-
- switch($clause) {
-
- case 'is':
- $handle = new Is($this);
- break;
-
- case 'requires':
- $handle = new Requires($this);
- break;
-
- case 'ensures':
- $handle = new Ensures($this);
- break;
-
- case 'throwable':
- $handle = new Throwable($this);
- break;
-
- case 'invariant':
- $handle = new Invariant($this);
- break;
-
- case 'behavior':
- $handle = new Collection(
- new Behavior($this),
- function ( Behavior $clause, $identifier ) {
-
- $clause->setIdentifier($identifier);
-
- return;
- }
- );
- break;
-
- case 'description':
- $handle = new Description($this);
- break;
-
- default:
- throw new \Hoa\Praspel\Exception\Model(
- 'Clause @%s is unknown.',
- 0, $clause);
- }
-
- return $this->_clauses[$clause] = $handle;
- }
-
- /**
* Get identifier (fallback).
*
* @access protected