/** * Constructor * * @param State $state State the caused the exception * @param string $setName Name of the state the object was expecting * @param \Exception $previous Optional previous exception */ public function __construct(State $state, $setName, \Exception $previous = null) { // Call the super constructor parent::__construct(sprintf('Trying to set state with name "%s" when object was expecting a state with name "%s"', $state->getName(), $setName), 0, $previous); // Set the properties $this->state = $state; $this->setName = $setName; }
public function testGetName() { $state = new State('test'); $this->assertEquals('test', $state->getName()); }
/** * Set the value of The followup state * * @param State state * * @return self */ public function setState(State $state) { if ($state->getName() === $this->stateName) { $this->state = $state; } else { throw new StateDoesNotMatchNameException($state, $this->stateName); } return $this; }
/** * Add a state to the workflow * * @param State $state State * * @return self */ public function addState(State $state) { // Check for name uniqueness if (array_key_exists($state->getName(), $this->states)) { throw new StateNameAlreadyUsedException($state->getName()); } $this->states[$state->getName()] = $state; return $this; }
/** * Get the name of the state being built * * @return string State name */ public function getStateName() { return $this->state->getName(); }