示例#1
0
 /**
  * @param IState $newState
  *
  * @return mixed
  *
  * @throws \Phur\StateMachine\Exception
  */
 public function changeState(IState $newState)
 {
     if (!$this->isValidState($newState)) {
         throw new Exception(get_class($newState) . " must implement interface {$this->moreSpecificInterface}!");
     }
     if ($this->currentState) {
         $this->currentState->after();
     }
     $this->currentState = $newState;
     return $this->currentState->before();
 }