public function validate(FsmInterface $fsm)
 {
     $count = count($fsm->getInitialStates());
     if ($count == 0) {
         throw new Exception\MissingInitialStateException($fsm);
     }
 }
 public function validate(FsmInterface $fsm, $throwExceptions = true)
 {
     $transitionsNames = array();
     foreach ($fsm->getTransitions() as $transition) {
         $transitionsNames[] = $transition->getName();
     }
     $duplicateTransitions = $this->getDuplicates($transitionsNames);
     foreach ($duplicateTransitions as $duplicateTransition) {
         throw new Exception\DuplicateTransitionException($fsm, $duplicateTransition);
     }
 }
 public function validate(FsmInterface $fsm, $throwExceptions = true)
 {
     $statesNames = array();
     foreach ($fsm->getStates() as $state) {
         $statesNames[] = $state->getName();
     }
     $duplicateStates = $this->getDuplicates($statesNames);
     foreach ($duplicateStates as $duplicateState) {
         throw new Exception\DuplicateStateException($fsm, $duplicateState);
     }
 }
 public function validate(FsmInterface $fsm, $throwExceptions = true)
 {
     foreach ($fsm->getTransitions() as $transition) {
         if (!$fsm->getStateByName($transition->getFromStateName())) {
             throw new Exception\UndefinedStateException($fsm, $transition, $transition->getFromStateName());
         }
         if (!$fsm->getStateByName($transition->getToStateName())) {
             throw new Exception\UndefinedStateException($fsm, $transition, $transition->getToStateName());
         }
     }
 }
 public function validate(FsmInterface $fsm)
 {
     $count = 0;
     foreach ($fsm->getStates() as $state) {
         if ($state->getIsInitial()) {
             $count++;
         }
     }
     if ($count == 0) {
         throw new Exception\MissingInitialStateException($fsm);
     }
     if ($count > 1) {
         throw new Exception\MultipleInitialStatesException($fsm);
     }
 }
 public function __construct(FsmInterface $fsm, $transitionName, $code = 0, $previous = null)
 {
     $message = sprintf('Transition <%s> is already used in FSM <%s>', $transitionName, $fsm->getName());
     parent::__construct($message, $code, $previous);
 }
 public function __construct(FsmInterface $fsm, AccessorInterface $accessor, $code = 0, $previous = null)
 {
     $message = sprintf('FSM <%s>: Stateful class <%s> must have access methods for property <%s>', $fsm->getName(), $accessor->getObjectClass(), $accessor->getObjectProperty());
     parent::__construct($message, $code, $previous);
 }
 public function __construct(FsmInterface $fsm, $code = 0, $previous = null)
 {
     $message = sprintf('FSM <%s> has multiple initial states', $fsm->getName());
     parent::__construct($message, $code, $previous);
 }
 public function __construct(FsmInterface $fsm, TransitionInterface $transition, $stateName, $code = 0, $previous = null)
 {
     $message = sprintf('Cannot find state <%s> for FSM <%s> used in transition <%s>', $stateName, $fsm->getName(), $transition->getName());
     parent::__construct($message, $code, $previous);
 }
 public function __construct(FsmInterface $fsm, $expectedClass, StatefulInterface $object, $code = 0, $previous = null)
 {
     $message = sprintf('FSM <%s> expects an object of class <%s>. <%s> provided.', $fsm->getName(), $expectedClass, get_class($object));
     parent::__construct($message, $code, $previous);
 }
 public function __construct(FsmInterface $fsm, TransitionInterface $transition, $currentStateName, $code = 0, $previous = null)
 {
     $message = sprintf('Invalid transition <%s> from state <%s> to state <%s> on current state <%s> for FSM <%s>', $transition->getName(), $transition->getFromStateName(), $transition->getToStateName(), $currentStateName, $fsm->getName());
     parent::__construct($message, $code, $previous);
 }