{@inheritdoc}

@throws Exception\StateException
336523
public function apply($transitionName, array $parameters = array())
    {
        $transition = $this->getTransition($transitionName);
        $event = new TransitionEvent($this->getCurrentState(), $transition, $this, $parameters);
        if (!$this->can($transition, $parameters)) {
            throw new Exception\StateException(sprintf(
                'The "%s" transition can not be applied to the "%s" state of object "%s" with graph "%s".',
                $transition->getName(),
                $this->currentState->getName(),
                get_class($this->getObject()),
                $this->getGraph()
            ));
        }

        $this->dispatchTransitionEvent($transition, $event, FiniteEvents::PRE_TRANSITION);

        $returnValue = $transition->process($this);
        $this->stateAccessor->setState($this->object, $transition->getState());
        $this->currentState = $this->getState($transition->getState());

        $this->dispatchTransitionEvent($transition, $event, FiniteEvents::POST_TRANSITION);

        return $returnValue;
    }
734227
public function setObjectState($object, $state)
    {
        if (is_object($object)) {
            $oid = spl_object_hash($object);
            $repository = $this->objectsRepository[$oid];
            $data = $repository->getHydrator()->unhydrate($object);
            $id = isset($data['_id']) ? serialize($data['_id']) . $repository->getCollection() : $oid;
        } else {
            return false;
        }

        if (!isset($this->objectStates[$id]) && !isset($this->objectStates[$oid])) {
            throw new Exception\StateException();
        }

        if (!in_array($state, [self::OBJ_MANAGED, self::OBJ_NEW, self::OBJ_REMOVED])) {
            throw new Exception\StateException("Invalid state '$state'");
        }

        if ($state == self::OBJ_REMOVED && isset($this->objectStates[$oid]) && $this->objectStates[$oid] == self::OBJ_NEW) {
            throw new Exception\StateException("Can't change state to removed because object is not managed. Insert it in database before");
        }

        if (isset($this->objectStates[$oid])) {
            unset($this->objectStates[$oid]);
            unset($this->objects[$oid]);
        }

        $this->objectStates[$id] = $state;
        $this->objects[$id] = $object;

        return true;
    }
689841
protected function initializeStates()
    {
        if (!array_key_exists('states', $this->vars)) {
            throw new WorkflowException("You must define some states:\n", 99, NULL);
        }

        //check if all the methods for each status is callable
        $methods_not_implemented = '';
        try {
            foreach ($this->vars['states'] as $status) {
                array_push($this->states, new Status($status));

                /*
                 * The initial state will never be executed but only the transitions, therefore it will be excluded
                 * from the list of methods which must be implemented
                 */
                if (!method_exists($this, $status['name'])
                    && $status['type'] != \Mothership\StateMachine\StatusInterface::TYPE_INITIAL
                    && $status['type'] != \Mothership\StateMachine\StatusInterface::TYPE_EXCEPTION) {
                    $methods_not_implemented .= $status['name'] . "\n";
                }
            }
        } catch (StatusException $ex) {
            throw new WorkflowException("Error in one state of the workflow:\n" . $ex->getMessage(), 79);
        }

        if (strlen($methods_not_implemented) > 0) {
            throw new WorkflowException(
                "This methods are not implemented in the workflow:\n" .
                $methods_not_implemented, 79, NULL
            );
        }
    }
649899
public function setState($state)
    {
        if (!in_array($state, $this->validStates)) {
            throw new InvalidArgumentException("Invalid editor state: $state");
        }

        $this->state = $state;

        $this->session->put($this->statePersistenceKey, $state);

        return $this;
    }
1059743
public function execute(State $state) {
        $errors = [];
        foreach ($state->functionLookup as $name => $functions) {
            $calls = $state->callFinder->getCallsForFunction($name);
            foreach ($functions as $func) {
                foreach ($calls as $call) {
                    $errors = array_merge($errors, $this->verifyCall($func, $call[0], $state, $name));
                }
            }
        }
        foreach ($state->internalTypeInfo->functions as $name => $arginfo) {
            $calls = $state->callFinder->getCallsForFunction($name);
            foreach ($calls as $call) {
                $errors = array_merge($errors, $this->verifyInternalCall($arginfo, $call[0], $state, $name));
            }
        }
        foreach ($state->methodCalls as $call) {
            if (!$call->name instanceof Operand\Literal) {
                // Variable method call
                continue;
            }
            if (!$call->var->type || $call->var->type->type !== Type::TYPE_OBJECT) {
                // We don't know the type
                continue;
            }
            $name = strtolower($call->var->type->userType);
            if (!isset($state->classResolves[$name])) {
                // Could not find class
                continue;
            }
            foreach ($state->classResolves[$name] as $cn => $class) {
                // For every possible class that can resolve the type
                $method = $this->findMethod($class, $name);
                if (!$method) {
                    // Class does not *directly* implement method
                    continue;
                }
                $errors = array_merge($errors, $this->verifyCall($method, $call, $state, $cn . "->" . $name));
            }
        }
        return $errors;
    }
836582
public function state($key = null, $default = null)
    {
        if ($key !== null) {
            return isset($this->state[$key]) ? $this->state[$key] : $default;
        }

        return $this->state;
    }
822864
public function put(StateInterface $state): self
    {
        $cloned_map = clone $this;
        $cloned_map->internal_map->put($state->getName(), $state);
        return $cloned_map;
    }
287796
protected function generateOne($field, $state)
    {
        $arguments = $field->options['arguments'];

        if (count($arguments) < 3) {
            throw new Exception('too few arguments');
        }

        list($class, $key, $value) = $arguments;

        if (!class_exists($class)) {
            throw new Exception($class . ' does not exist');
        }

        $object = $class::get()->filter($key, $value)->first();

        if (is_null($object)) {
            throw new Exception('object not found');
        }

        return $object;
    }
940144
public function states($states = null)
    {
        if ($states === null) {
            return $this->_states;
        } else {
            unset($states['id']);
            foreach ($states as $key => $value) {
                $this->_states[$key] = $value;
            }
            $this->save();
        }
    }
422840
public function setState(int $state): ControllerInterface
    {
        switch ($state) {
            case self::STATE_PLAYING:
                return $this->play();
            case self::STATE_PAUSED:
                return $this->pause();
            case self::STATE_STOPPED:
                return $this->pause();
        }
        throw new \InvalidArgumentException("Unknown state: {$state})");
    }
1006485
function setState($state) {
		if($state == (self::SMOKE_DETECTOR_STATE_SMOKE_ALARM_ON or self::SMOKE_DETECTOR_STATE_SMOKE_ALARM_OFF))
			$this->state = $state;
		else
			throw new \Exception('Invalid SmokeDetectorSensor state "'.$state.'"');
	}
1310751
public function acceptance(array $states = [], $verbose = false)
    {
        if (count($states) < 2) {
            throw new \Exception('Automata needs at least two states');
        }

        foreach ($states as $index => $state) {
            $condition = (array_key_exists('return', $state)) ? $state['return'] : NULL;

            if ($index + 1 == count($states) || $state['name'] == 'finish') {
                continue;
            }

            $nextState = $this->getNextStateFrom($state['name'], $condition);

            $message = sprintf(
                'δ: (C × Z[%d] → Z[%d) = [%s] x [%s] → [%s] ',
                $this->getStatusIndex($state['name']),
                $this->getStatusIndex($states[$index + 1]['name']),
                var_export($condition, true),
                $state['name'],
                $states[$index + 1]['name']
            );
            if ($nextState->getName() !== $states[$index + 1]['name']) {
                throw new \Exception('Invalid transition. Last transition: ' . $message . ' . Given: ' . $nextState->getName());
            }

            if (true === $verbose) {
                $this->output->writeln($message);
            }
        }

        return true;
    }
868392
public function setState(StateInterface $state): StateManagerInterface
    {
        $this->collection->offsetSet($state->getIdentifier()->getId(), $state);
        
        return $this;
    }
667942
public function push($type, $state = []) {
        if (isset($this->_defaults[$type])) {
            $state = array_merge($this->_defaults[$type], $state);
        }
        array_push($this->_states, [$type, $state]);
    }
250969
function setState($state) {
		if($state == (self::GENERIC_ACTUATOR_STATE_ON or self::GENERIC_ACTUATOR_STATE_OFF))
			$this->state = $state;
		else
			throw new \Exception('Invalid GenericActuator state "'.$state.'"');
	}
235360
protected function _setStateAware($stateAware)
    {
        if ($stateAware !== null && !($stateAware instanceof StateAwareInterface)) {
            throw $this->_createInvalidArgumentException(
                $this->__('Argument is not a state aware object'),
                null,
                null,
                $stateAware
            );
        }

        $this->stateAware = $stateAware;
    }
868180
protected function _setState($state)
    {
        if ($state !== null && !($state instanceof MapInterface)) {
            throw $this->_createInvalidArgumentException(
                $this->__('Argument is not a valid map'), null, null, $state
            );
        }

        $this->state = $state;
    }