/** * Returns the states the machine would be in, after the given transition * * @param Model $model The model being acted on * @param string $transition The transition name * @return mixed False if the transition doesnt yield any states, or an array of states */ public function getStates(Model $model, $transition) { if (!isset($model->transitions[$transition])) { // transition doesn't exist return false; } // get the states the machine can move from and to $states = $model->transitions[$transition]; $currentState = $model->getCurrentState(); if (isset($states[$currentState])) { return $states[$currentState]; } if (isset($states['all'])) { return $states['all']; } return false; }