/** * @see \FSM\Transition\TransitionInterface::accept() */ public function accept() { if ($this->isAcceptible()) { $this->sourceState->getContext()->setState($this->targetState); return $this; } throw new \BadMethodCallException("Current transition can not be accepted"); }
/** * Internal machine context state setter * * @param ContextInterface $context * @param StateInterface $state * @return void */ private function setContextState(ContextInterface $context, StateInterface $state) { $context->setContextState($state->getName()); }
/** * Apply initial state * s * @param \FSM\State\StateInterface $state * @throws \FSM\Exception\ClientInitializationException */ public function setInitialState(StateInterface $state) { if (!$state->isInitial()) { throw new ClientInitializationException("The first State should be of type Initial."); } elseif (!in_array($state, $this->states)) { throw new ClientInitializationException("Can not apply state as initial. " . "The state was never registered."); } $this->context->setState($state); return $this; }