X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=application%2Fhub%2Fmain%2Fstates%2Fpeer%2Fclass_BasePeerState.php;h=e95c5c3624acc2b36ee6c7ced502432c47cf732c;hb=dfe38c5c2ff89adebea4f61364eb556a83da35a3;hp=7b6b3814dca16753014261f5bc4732c0d6329826;hpb=1212b8422d9040c36c355c2c81c689dda7fd79ad;p=hub.git diff --git a/application/hub/main/states/peer/class_BasePeerState.php b/application/hub/main/states/peer/class_BasePeerState.php index 7b6b3814d..e95c5c362 100644 --- a/application/hub/main/states/peer/class_BasePeerState.php +++ b/application/hub/main/states/peer/class_BasePeerState.php @@ -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]