aboutsummaryrefslogtreecommitdiffstats
path: root/Model
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2013-04-23 15:54:50 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2013-04-23 15:54:50 +0200
commit73afcad19993e283d0945a3d5be25b8250ef4898 (patch)
tree6ee36925fd7eb12b3e2858ce70003c66bce6dc15 /Model
parent057439b846af197af8f15e19c4b7adac8bf589ef (diff)
downloadPraspel-73afcad19993e283d0945a3d5be25b8250ef4898.zip
Praspel-73afcad19993e283d0945a3d5be25b8250ef4898.tar.gz
Praspel-73afcad19993e283d0945a3d5be25b8250ef4898.tar.bz2
New @throwable clause API.
Diffstat (limited to 'Model')
-rw-r--r--Model/Throwable.php61
1 files changed, 54 insertions, 7 deletions
diff --git a/Model/Throwable.php b/Model/Throwable.php
index f0f639c..5a13658 100644
--- a/Model/Throwable.php
+++ b/Model/Throwable.php
@@ -57,7 +57,11 @@ namespace Hoa\Praspel\Model {
* @license New BSD License
*/
-class Throwable extends Clause implements \IteratorAggregate, \Countable {
+class Throwable
+ extends Clause
+ implements \ArrayAccess,
+ \IteratorAggregate,
+ \Countable {
/**
* Name.
@@ -76,17 +80,60 @@ class Throwable extends Clause implements \IteratorAggregate, \Countable {
/**
- * Add an exception to the list.
+ * Check if an exception identifier exists.
*
* @access public
- * @param string $exception Exception name.
- * @return \Hoa\Praspel\Model\Throwable
+ * @param string $offset Exception identifier.
+ * @return bool
*/
- public function exception ( $exception ) {
+ public function offsetExists ( $offset ) {
- $this->_exceptions[] = $exception;
+ return isset($this->_exceptions[$offset]);
+ }
+
+ /**
+ * Get an exception.
+ *
+ * @access public
+ * @param string $offset Exception identifier.
+ * @return \Hoa\Prasel\Model\Variable
+ */
+ public function offsetGet ( $offset ) {
+
+ if(false === $this->offsetExists($offset))
+ return null;
+
+ return $this->_exceptions[$offset];
+ }
+
+ /**
+ * Add an exception.
+ *
+ * @access public
+ * @param string $offset Exception identifier.
+ * @param mixed $value Exception classname.
+ * @return mixed
+ */
+ public function offsetSet ( $offset, $value ) {
+
+ $old = $this->offsetGet($offset);
+ $this->_exceptions[$offset] = $value;
+
+ return $old;
+ }
+
+ /**
+ * Delete an exception.
+ *
+ * @access public
+ * @param string $offset Exception identifier.
+ * @return void
+ */
+ public function offsetUnset ( $offset ) {
+
+ unset($this->_exceptions[$offset]);
- return $this;
+ return;
}
/**