@param StateInterface $state

@return int
174156
public function track(StateInterface $state): int
    {
        $this->breadcrumbs->push($state->getName());
        $this->execution_counts[$state->getName()]++;
        return $this->execution_counts[$state->getName()];
    }
1146706
public function getStateCandidates(int $state): array
    {
        $candidates = [];

        foreach ($this->candidates as $candidateId => $candidate) {
            if ($candidate->getState() == $state) {
                $candidates[$candidateId] = $candidate;
            }
        }

        return $candidates;
    }
867374
private function getToState(StateInterface $fromState, $methodName)
    {
        if (!method_exists($fromState, $methodName)) {
            throw new UnsupportedStateTransitionException(
                sprintf('State %s has no method %s.', $fromState->getKey(), $methodName)
            );
        }

        return call_user_func(array($fromState, $methodName), new StubHasState());
    }
542266
public function setState($state=0, $ids=array())
	{
		if (count($ids) <= 0)
		{
			return false;
		}

		$ids = array_map('intval', $ids);

		return $this->update()
			->set(array('state' => $state))
			->whereIn('id', $ids)
			->execute();
	}
217046
public function checkState($storeState, $state = null)
	{
		if(null === $state)
		{
			if(null === $this->state)
			{
				if(isset($_GET['state']))
				{
					$state = $_GET['state'];
				}
				else
				{
					$state = '';
				}
			}
			else
			{
				$state = $this->state;
			}
		}
		return $storeState === $state;
	}
1246201
public function getState() : ?int 
    {
        if ( ! $this->hasState()) {
            $this->setState($this->getDefaultState());
        }
        return $this->state;
    }
125370
protected function initSchema(State $state)
    {
        parent::initSchema($state);

        //Reading table schema
        $this->engine = $this->driver->query('SHOW TABLE STATUS WHERE `Name` = ?', [
            $state->getName()
        ])->fetch()['Engine'];
    }
273198
public function createResult(ConfigurationInterface $moduleConfiguration, StateInterface $state)
    {
        if (false === $this->_AllowCache($moduleConfiguration)) {
            return $this->resultFactory->createResult($moduleConfiguration, $state);
        }
        $key = $this->getKey($moduleConfiguration, $state);
        $resultData = $this->cache->get($key);
        if (null !== $resultData) {
            $this->dispatchCachedFilterExecutedEvent($resultData, $moduleConfiguration, $state);

            return $resultData;
        }

        $resultData = $this->resultFactory->createResult($moduleConfiguration, $state);

        $this->cache->set($key, $resultData, $this->getTrigger($moduleConfiguration));

        return $resultData;
    }
1039098
public function incTry(IState &$state = null): int
    {
        $count = (int) $state->getAdditional(static::STATE__CURRENT_TRIES_COUNT);
        $count++;
        $state->setAdditional(static::STATE__CURRENT_TRIES_COUNT, $count);

        return $count;
    }
885722
public function setState($state = null)
        {
            if (null === $state) {
                $this->_state = $state;
                return $this;
            }

            if (in_array($state, array(static::STATE_SUCCESS, static::STATE_ERROR, static::STATE_INFO))) {
                $this->_state = $state;
            }

            return $this;
        }
141558
protected function execute(InputInterface $input, OutputInterface $output): ?int
    {
        $username = $this->getUsername($input, $output);
        if ($input->getOption('if-not-exists')) {
            try {
                $user = $this->userManager->loadUserByUsername($username);
            } catch (\Exception $e) {
                $user = null;
            }
            if ($user) {
                $message = $this->translator->trans(
                    'user.already_exists',
                    [
                        '%username%' => $username,
                    ],
                    'security'
                );
                $output->writeln("<comment>{$message}</comment>");

                return 0;
            }
        }

        try {
            $user = $this->userManager->createUser($username);
        } catch (BadUsernameException $e) {
            $output->writeln("<error>{$e->getMessage()}</error>");

            return 1;
        }

        $user->setSuperAdmin($input->getOption('admin'));
        $password = $this->getPassword($input, $output);
        if ($password) {
            $this->userManager->setPlainTextPassword($user, $password);
        }
        $this->userManager->save($user);

        $message = $this->translator->trans('user.created_success', ['%username%' => $username], 'security');
        $output->writeln("<info>{$message}</info>");

        return 0;
    }
714249
public function getState($state = null)
	{
		if ($state === null) {
			$state = $this->getValue();
		}

		if (!isset($this->states[$state])) {
			return 'default';
		}

		return $this->states[$state];
	}
998662
private function pushCallerStatedClassName(StateInterface $state): ProxyInterface
    {
        $stateClass = \get_class($state);

        if (!isset($this->classesByStates[$stateClass])) {
            throw new \RuntimeException("Error, no original class name defined for $stateClass");
        }

        $this->callerStatedClassesStack->push($this->classesByStates[$stateClass]);

        return $this;
    }
1038823
protected function getState($state = null)
	{
		if(null === $state)
		{
			if(null === $this->state)
			{
				$this->state = md5(\uniqid('', true));
			}
		}
		else
		{
			$this->state = $state;
		}
		return $this->state;
	}
1083115
public function execute(State $state) {
        $errors = [];
        foreach ($state->newCalls as $new) {
            $type = null;
            if ($new->class instanceof Operand\Literal) {
                $type = $new->class->value;
            } elseif ($new->class->type->type !== Type::TYPE_OBJECT) {
                $errors[] = ["Unknown class type for new call", $new];
                continue;
            } else {
                $type = $new->class->type->userType;
            }
            $name = strtolower($type);
            if (!isset($state->classResolves[$name])) {
                if (isset($state->internalTypeInfo->methods[$name])) {
                    // TODO
                } else {
                    $errors[] = ["Could not find class definition for $type", $new];
                }
                continue;
            }
            foreach ($state->classResolves[$name] as $sub => $class) {
                $constructor = $this->findConstructor($class);
                if ($constructor) {
                    // validate parameters!!!
                    $errors = array_merge($errors, $this->verifyCall($constructor, $new, $state, "{$class->name->value}::__construct"));
                }
            }
        }
        return $errors;
    }
1338305
public function createStatusVertex(StateInterface $state)
    {
        $stateName = $state->getName();
        $vertex = $this->graph->createVertex($stateName, true);
        if ($state instanceof \ArrayAccess) {
            $layout = $this->getLayoutOptions($state, $this->stateLayout);
            if (method_exists($vertex, 'setLayout')) {
                $vertex->setLayout($layout);
            } else {
                foreach ($layout as $name => $value) {
                    $vertex->setAttribute('graphviz.' . $name, $value);
                }
            }
        }

        return $vertex;
    }
80140
public static int from(String state) {
        switch (state.toUpperCase()) {
            case ACTIVE:
                return Bundle.ACTIVE;
            case INSTALLED:
                return Bundle.INSTALLED;
            case RESOLVED:
                return Bundle.RESOLVED;
            case STARTING:
                return Bundle.STARTING;
            case STOPPING:
                return Bundle.STOPPING;
            case UNINSTALLED:
                return Bundle.UNINSTALLED;
            default:
                return -1; // Unknown.
        }
    }