Author: Oliver Tischlinger
Inheritance: implements MetaborStd\Statemachine\TransitionInterface, implements MetaborStd\WeightedInterface
Ejemplo n.º 1
0
 /**
  *
  */
 public function testThrowsAnExceptionIfMoreThanOneTransitionHasHighestWeight()
 {
     $targetState = new State('TargetState');
     $transitions = array();
     $transition = new Transition($targetState);
     $transition->setWeight(0.001);
     $transitions[] = $transition;
     $transition = new Transition($targetState);
     $transition->setWeight(0.001);
     $transitions[] = $transition;
     $selector = new WeightTransition();
     $this->setExpectedException('\\RuntimeException');
     $selector->selectTransition(new \ArrayIterator($transitions));
 }
Ejemplo n.º 2
0
 /**
  * @param TransitionInterface $sourceTransition
  *
  * @throws \InvalidArgumentException
  *
  * @return \Metabor\Statemachine\Transition
  */
 protected function createTransition(TransitionInterface $sourceTransition)
 {
     $targetStateName = $sourceTransition->getTargetState()->getName();
     $targetState = $this->findOrCreateState($targetStateName);
     $this->mergeMetadata($sourceTransition->getTargetState(), $targetState);
     $eventName = $sourceTransition->getEventName();
     $condition = $this->createCondition($sourceTransition);
     $transition = new Transition($targetState, $eventName, $condition);
     if ($sourceTransition instanceof WeightedInterface) {
         $transition->setWeight($sourceTransition->getWeight());
     }
     return $transition;
 }