aboutsummaryrefslogtreecommitdiffstats
path: root/Model
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2013-11-01 17:30:24 +0100
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2013-11-01 17:30:24 +0100
commitc4f955afb4014ff8c4a302ef1ea82afa2d8d708d (patch)
tree3c1d9e3a54d98bd5028c181897b70420020059cb /Model
parent057c5994422f58b329e63a0672da0f6f33e13355 (diff)
downloadPraspel-c4f955afb4014ff8c4a302ef1ea82afa2d8d708d.zip
Praspel-c4f955afb4014ff8c4a302ef1ea82afa2d8d708d.tar.gz
Praspel-c4f955afb4014ff8c4a302ef1ea82afa2d8d708d.tar.bz2
Add the addClause() method.
Diffstat (limited to 'Model')
-rw-r--r--Model/Behavior.php21
1 files changed, 20 insertions, 1 deletions
diff --git a/Model/Behavior.php b/Model/Behavior.php
index 362f9f4..efa7c31 100644
--- a/Model/Behavior.php
+++ b/Model/Behavior.php
@@ -141,7 +141,7 @@ class Behavior extends Clause {
/**
- * Get a specific clause.
+ * Get or create a specific clause.
*
* @access public
* @param string $clause Clause (without leading arobase).
@@ -212,6 +212,25 @@ class Behavior extends Clause {
}
/**
+ * Add a clause.
+ *
+ * @access public
+ * @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 \Hoa\Praspel\Exception\Model(
+ 'Clause @%s is not allowed in @%s.',
+ 0, array($name, $this->getId()));
+
+ return $this->_clauses[$name] = $clause;
+ }
+
+ /**
* Check if a clause already exists, i.e. has been declared.
*
* @access public