Named scope to fetch all models having a state higher than the one provided

@param integer|string $stateValue the value of the state to check
@return \asinfotrack\yii2\toolbox\behaviors\StateQueryBehavior
340017
public function higherThanState($stateValue)
	{
		//validate state
		$this->modelInstance->stateExists($stateValue, true);
		//apply to query
		$this->owner->andWhere(['IN', $this->stateAttribute, $this->getStateSelection($stateValue, static::STATES_HIGHER)]);
		return $this->owner;
	}
301162
public function get($state_id)
    {
        $result = &gplcart_static("state.get.$state_id");

        if (isset($result)) {
            return $result;
        }

        $this->hook->attach('state.get.before', $state_id, $result, $this);

        if (isset($result)) {
            return $result;
        }

        $result = $this->db->fetch('SELECT * FROM state WHERE state_id=?', array($state_id));
        $this->hook->attach('state.get.after', $state_id, $result, $this);
        return $result;
    }
1043810
public function get($state) : State
    {
        $this->addCallback('GET', $state);
        if (!isset($this->actions['POST'])) {
            $this->addCallback('POST', $state);
        }
        return $this;
    }
1122264
public function setState($state)
		{
		$r = array_pop($this->states);
		array_push($this->states, $state);
		$this->state = $this->states[count($this->states) - 1];
		return $r;
		}
366905
public function exchangeArray(array $state) {
		if ($this instanceof IValueObject && $this->isExchanged())
			throw new Exception("Cannot change ValueObjects. Create new object instead");
		if ($this instanceof IValidatorAware && !is_null($this->getValidator()) &&
			!$this->getValidator()->isValid($state)) {
			$stateRep = array();
			foreach ($state as $key => $val)
				$stateRep[] = $key.' => '.
					(is_object($val)?'[Object]':(is_resource($val)?'[Resource]':var_export($val,true)));
			throw new InvalidStateException("ExchangeArray called with an invalid state: ".
				             var_export($this->getValidator()->getMessages(),true)."\n\n(".implode(',',$stateRep).')');
		}
		$toSet = $this->getStateVarsWithAll();
		foreach ($this->getStateVO() as $voIndex)
			if (isset($state[$voIndex])) {
				$vo = $state[$voIndex];
				if ($vo instanceof IExchangeState)
					$state = array_merge($state,$vo->getArrayCopy());
			}

		foreach ($toSet as $var) {
			if (isset($state[$var])) {
				$value = $state[$var];
				if ($this instanceof IValueObject && $value instanceof IFreezable) $value->freeze();
				// @TODO Add fields of ValueObjects to motherObject
				$this->{self::_privatizeField($var)} = $value;
			}
			else
				$this->{self::_privatizeField($var)} = null;
		}
		if ($this instanceof IValueObject)
			$this->markExchanged();
	}
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})");
    }
231848
public function meetsStatePreconditions($stateValue)
	{
		$config = $this->getStateConfig($stateValue);
		if (isset($config['preconditionCallback'])) {
			return call_user_func($config['preconditionCallback'], $this->owner, $config);
		} else {
			return true;
		}
	}
1077085
protected function parseValidatorAnnotation($validateValue)
    {
        $matches = [];
        if ($validateValue[0] === '$') {
            $parts = explode(' ', $validateValue, 2);
            $validatorConfiguration = ['argumentName' => ltrim($parts[0], '$'), 'validators' => []];
            preg_match_all(self::PATTERN_MATCH_VALIDATORS, $parts[1], $matches, PREG_SET_ORDER);
        } else {
            $validatorConfiguration = ['validators' => []];
            preg_match_all(self::PATTERN_MATCH_VALIDATORS, $validateValue, $matches, PREG_SET_ORDER);
        }
        foreach ($matches as $match) {
            $validatorOptions = [];
            if (isset($match['validatorOptions'])) {
                $validatorOptions = $this->parseValidatorOptions($match['validatorOptions']);
            }
            $validatorConfiguration['validators'][] = ['validatorName' => $match['validatorName'], 'validatorOptions' => $validatorOptions];
        }
        return $validatorConfiguration;
    }
1300834
public function setModelState($providerName, $modelId, $state)
    {
        if (!isset($this->states[$providerName])) {
            $this->states[$providerName] = [];
        }

        $this->states[$providerName][$modelId] = (bool) $state;

        return $this;
    }
742372
public function getStateConfig($stateValue=null)
	{
		if ($stateValue === null) {
			$stateValue = $this->owner->{$this->stateAttribute};
		} else {
			$this->stateExists($stateValue, true);
		}
		return $this->cacheConfigMap[$stateValue];
	}
1178931
protected function setState($state)
    {
        if (!array_key_exists($state, $this->stateDirectives)) {
            throw new InvalidArgumentException("Invalid state {$state}");
        }
        $this->state = $state;
        return $this;
    }
748790
public function getState()
    {
        if(!$this->__state instanceof KModelStateInterface)
        {
            $this->__state = $this->getObject($this->__state, array('model' => $this));

            if(!$this->__state instanceof KModelStateInterface)
            {
                throw new UnexpectedValueException(
                    'State: '.get_class($this->__state).' does not implement KModelStateInterface'
                );
            }
        }

        return $this->__state;
    }
1157150
final public static function box($plainValue): self
    {
        foreach (static::valueNames() as $name) {
            if (self::constant($name) === $plainValue) {
                return self::__callStatic($name, []);
            }
        }

        $message = sprintf('Value %s is not within %s enumeration.', $plainValue, static::class);
        throw new InvalidArgumentException($message);
    }
957079
public function getContextConfigValue($varName, $defaultValue = null)
    {
        if ($this->type == InternalBaseBlock::INJECTOR_VAR) {
            return $this->context->getVarValue($varName, $defaultValue);
        }
        
        if ($this->type == InternalBaseBlock::INJECTOR_CFG) {
            return $this->context->getCfgValue($varName, $defaultValue);
        }
            
        throw new InvalidConfigException("The type '{$this->type}' is not supported.");
    }
1051290
public function getModel()
    {
        if(!$this->_model instanceof ModelInterface)
        {
            $this->_model = $this->getObject($this->_model);

            if(!$this->_model instanceof ModelInterface)
            {
                throw new \UnexpectedValueException(
                    'Model: '.get_class($this->_model).' does not implement ModelInterface'
                );
            }

            //Inject the request into the model state
            $this->_model->setState($this->getRequest()->query->toArray());
        }

        return $this->_model;
    }
271684
public function get($key, $defaultValue = null)
    {
        if (isset($this->session[$key]) && !empty($this->session[$key])) {
            return $this->session[$key];
        }

        return $defaultValue;
    }
250643
private function createStateMachine($stateMachineName)
    {
        $stateMachine = new StateMachine($stateMachineName);
        $stateMachine->addState(new InitialState());
        $stateMachine->addState(new FinalState());
        $stateMachine->addState(new State(self::$STATE_START));
        $stateMachine->addTransition(
            $stateMachine->getState(StateInterface::STATE_INITIAL),
            new TransitionEvent(EventInterface::EVENT_START),
            $stateMachine->getState(self::$STATE_START),
            null,
            null
        );

        return $stateMachine;
    }