]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/states/node/class_BaseNodeState.php
State pattern added, hub continued (sorry, I let it lay around uncommitted for long...
[hub.git] / application / hub / main / states / node / class_BaseNodeState.php
index 5e87659993cb48d9f76eba7563ef01eabe6807c5..941be516263cfb9e18ff486e21b6b83653027f73 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * A general Node state class
+ * A general node state class
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
@@ -32,6 +32,21 @@ class BaseNodeState extends BaseState {
                // Call parent constructor
                parent::__construct($className);
        }
+
+       /**
+        * Validates wether the state is 'active' or throws an exception if
+        * it is every other state.
+        *
+        * @return      void
+        * @throws      InvalidStateException   If the state is not 'active'
+        */
+       public function validateNodeStateIsActive () {
+               // Just compare it...
+               if (!$this instanceof NodeActiveState) {
+                       // Throw the exception
+                       throw new InvalidStateException($this, self::EXCEPTION_INVALID_STATE);
+               } // END - if
+       }
 }
 
 // [EOF]