/**
  * Sets the exit action to the state.
  *
  * @param string   $stateId
  * @param callback $action
  *
  * @throws ActionNotCallableException
  * @throws StateNotFoundException
  */
 public function setExitAction($stateId, $action)
 {
     $state = $this->stateMachine->getState($stateId);
     if ($state === null) {
         throw new StateNotFoundException(sprintf('The state "%s" is not found in the state machine "%s".', $stateId, $this->stateMachine->getStateMachineId()));
     }
     if (!is_callable($action)) {
         throw new ActionNotCallableException(sprintf('The action for the event "%s" in the state "%s" is not callable.', EventInterface::EVENT_EXIT, $stateId));
     }
     $state->getEvent(EventInterface::EVENT_EXIT)->setAction($action);
 }