/**
  * Constructor
  *
  * @param Input $input
  * @param Stateful $object
  * @param Context $context
  * @param State $nextState
  * @param \Exception $previous (Optional)
  */
 public function __construct(Input $input, Stateful $object, Context $context, State $nextState, \Exception $previous = null)
 {
     $message = sprintf('Failed attempting to %s a %s with current state %s', $input->getName(), get_class($object), $object->getCurrentStateName());
     parent::__construct($message, 0, $previous);
     $this->object = $object;
     $this->context = $context;
     $this->input = $input;
     $this->nextState = $nextState;
 }
 /**
  * Returns the key to use to store the action involving application of an
  * input to a given state internally.
  *
  * @param State $currentState
  * @param Input $input
  *
  * @return string
  */
 private function getActionKey(State $currentState, Input $input) : string
 {
     return sprintf('%s | %s', $currentState->getName(), $input->getName());
 }
Exemplo n.º 3
0
 /**
  * Prepares exception message that includes the invalid input and state
  *
  * @param Input $input
  * @param State $state
  */
 public function __construct(Input $input, State $state)
 {
     $this->input = $input;
     $this->state = $state;
     parent::__construct(sprintf('Cannot %s a %s object', $input->getName(), $state->getName()));
 }
Exemplo n.º 4
0
 /**
  * Creates an event name based on an input, current state, and when that event should be emitted
  *
  * @param string $executedWhen
  * @param Input $input
  * @param State $currentState
  *
  * @return string
  */
 private function getEventName(string $executedWhen, Input $input, State $currentState) : string
 {
     return sprintf('%s %s %s', $executedWhen, $input->getName(), $currentState->getName());
 }