Beispiel #1
0
 /**
  * Internal machine context state setter
  *
  * @param ContextInterface $context
  * @param StateInterface   $state
  * @return void
  */
 private function setContextState(ContextInterface $context, StateInterface $state)
 {
     $context->setContextState($state->getName());
 }
Beispiel #2
0
 /**
  * Add state
  * 
  * @todo Context interface schould be checked
  * @param \FSM\State\StateInterface $state
  * @throws \FSM\Exception\ClientInitializationException
  * @return \FSM\AbstractClient
  */
 public function addState(StateInterface $state)
 {
     if (!is_object($this->context)) {
         throw new ClientInitializationException("Context schould be set first.");
     } elseif (!$state->getName()) {
         throw new ClientInitializationException("Can not register state without a name.");
     } elseif ($this->getStateByName($state->getName()) !== null) {
         throw new ClientInitializationException("Can not register state. The state with the same name already exists.");
     } elseif (!($state->isFinite() || $state->isInitial() || $state->isRegular())) {
         throw new ClientInitializationException("Can not add state without a type.");
     }
     $state->setContext($this->context);
     $this->states[$state->getName()] = $state;
     return $this;
 }