]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/states/peer/class_BasePeerState.php
Fixed a typo, added an assert()
[hub.git] / application / hub / main / states / peer / class_BasePeerState.php
index 7b6b3814dca16753014261f5bc4732c0d6329826..e95c5c3624acc2b36ee6c7ced502432c47cf732c 100644 (file)
@@ -32,6 +32,31 @@ class BasePeerState extends BaseState {
                // Call parent constructor
                parent::__construct($className);
        }
+
+       /**
+        * Validates whether the state is 'connected' or throws an exception if
+        * it is every other state.
+        *
+        * @return      void
+        * @throws      InvalidStateException   If the state is not 'connected'
+        */
+       public function validatePeerStateConnected () {
+               // Just compare it...
+               if (!$this->isPeerStateConnected()) {
+                       // Throw the exception
+                       throw new InvalidStateException($this, self::EXCEPTION_INVALID_STATE);
+               } // END - if
+       }
+
+       /**
+        * Checks whether the peer's state is 'connected'
+        *
+        * @return      $isConnected                    Whether the state is 'connected'
+        */
+       public function isPeerStateConnected () {
+               // Just compare it...
+               return ($this instanceof ConnectedPeerState);
+       }
 }
 
 // [EOF]