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) { $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); } }