Checks if the value is a valid condition string.

@param ActivationInterface $condition The condition instance that should be validated.
541391
public function isValid($condition)
    {
        $conditionTree = ConditionParser::get()
            ->parse($condition);

        if (true === $conditionTree->getValidationResult()->hasErrors()) {
            $errorMessage = $this->translateErrorMessage(
                'validator.form.condition_is_valid.error',
                'formz',
                [
                    $condition->getExpression(),
                    $conditionTree->getValidationResult()->getFirstError()->getMessage()
                ]
            );

            $this->addError($errorMessage, self::ERROR_CODE);
        }
    }
413892
protected function checkValue($value, $condition) {
        list($filterType, $valueToCheck) = $condition;

        switch ($filterType) {
            case self::FILTER_TYPE_EQ:
                return $valueToCheck == $value;

            case self::FILTER_TYPE_NEQ:
                return $valueToCheck != $value;

            case self::FILTER_TYPE_LIKE:
                return strpos($value, $valueToCheck) !== false;

            default :
                throw new InvalidFilterTypeException("Filter type '$filterType' is unknown'");
        }
    }
1228387
public static function that($condition, $message = null)
    {
        if ($condition === true) {
            return;
        }
        if (isset($message)) {
            throw new InvalidArgumentException($message);
        }
        $bt = debug_backtrace();
        $call = $bt[0];
        $lines = file($call['file']);
        preg_match('/' . $call['function'] . '\((.+)\)/', $lines[$call['line'] - 1], $matches);
        throw new InvalidArgumentException('Assumption failed: ' . $matches[1]);
    }
1305647
public function where( $condition ) {
		if ( ! $condition instanceof ConditionInterface ) {
			$condition = func_get_args();
		}

		$condition = $this->router->mergeConditionAttribute(
			$this->getAttribute( 'condition' ),
			$condition
		);

		return $this->attribute( 'condition', $condition );
	}
745104
public function setCondition($name, ConditionInterface $condition)
    {
        if (array_key_exists($name, $this->fields)) {
            $this->fields[$name] = $condition;

            return true;
        }

        $i = 0;
        $end = count($this->children);
        $set = false;

        while ($i < $end && !$set) {
            $set = $this->children[$i]->setCondition($name, $condition);
            $i++;
        }

        return $set;
    }
384992
public function addCondition(ConditionAbstract $condition)
    {
        if ($condition instanceof MediaCondition) {
            $this->conditions[] = $condition;
        } else {
            throw new \InvalidArgumentException(
                "Invalid condition instance. Instance of 'MediaCondition' expected."
            );
        }

        return $this;
    }
411835
public function mapCondition(PersistenceCondition $condition): Condition
    {
        try {
            $conditionType = $this->conditionTypeRegistry->getConditionType(
                $condition->type
            );
        } catch (ConditionTypeException $e) {
            $conditionType = new NullConditionType();
        }

        $conditionData = [
            'id' => $condition->id,
            'status' => $condition->status,
            'ruleId' => $condition->ruleId,
            'conditionType' => $conditionType,
            'value' => $condition->value,
        ];

        return Condition::fromArray($conditionData);
    }
179232
public function checkCondition(Value $value)
    {
        if ($this->compareType($value) && $value->getValue() == $this->getValue()->getValue()) {
            return true;
        }

        return false;
    }
561945
public function removeCondition($condition)
    {
        if ($this->conditions->contains($condition)) {
            $this->conditions->removeElement($condition);
        }

        return $this;
    }
1122981
protected static function evaluateCondition($condition)
    {
        if (is_string($condition)) {
            // Should be extended for functions, extensions???
            return self::safeClassExists($condition);
        }
        if (is_callable($condition)) {
            return (bool) $condition();
        }
        if (is_bool($condition)) {
            return $condition;
        }
        if (is_array($condition)) {
            foreach ($condition as $c) {
                if (false === static::evaluateCondition($c)) {
                    // Immediately stop execution if the condition is false
                    return false;
                }
            }

            return true;
        }

        return false;
    }
469508
protected function compileCondition(ConditionContract $condition)
    {

        $operand = $condition->operand();

        $matcher = $this->compile($condition->constraint());

        return function ($data) use ($operand, $matcher) {
            return $matcher($this->value($data, $operand));
        };

    }
278198
protected function applyRootCondition(&$condition)
    {
        if (false !== $this->rootAttribute) {
            $condition[] = [$this->rootAttribute => $this->node->{$this->rootAttribute}];
        }
    }
347903
public function cas($condition, $value = null) {
		if (!is_null($value)) {
			$this->_switchValue = $value;
		}
		if ((is_null($this->_switchCondition) && true === $condition) ||
			(!is_null($this->_switchCondition) && $this->_switchCondition == $condition)) {
			return $this->_switchValue;
		}
		return null;
	}
870717
public static function addCondition($condition)
    {
        $ret = ' ';

        if (!empty($condition)) {
            if (is_array($condition)) {
                $ret .= ' AND (( ' . implode(" )\nAND (", $condition) . ' ))';
            } else {
                $ret .= ' AND ( ' . $condition . ' )';
            }
        }

        return $ret;
    }
328533
protected function validateCondition($condition)
    {
        $condition = trim(strtolower($condition));

        if ($condition !== 'and' && $condition !== 'or') {
            throw new QBParseException("Condition can only be one of: 'and', 'or'.");
        }

        return $condition;
    }
636238
private function _prepareCondition(ConditionInterface $condition = null)
	{
		$this->condition = $this->expressionBuilderFactory->create($condition)->build();
	}
904731
public function parseCondition($condition) {
        $condition = str_ireplace(array_keys($this->comparison),array_values($this->comparison),$condition);
        $condition = preg_replace('/\$(\w+):(\w+)\s/is','$\\1->\\2 ',$condition);
        switch(strtolower(C('TMPL_VAR_IDENTIFY'))) {
            case 'array': // 识别为数组
                $condition  =   preg_replace('/\$(\w+)\.(\w+)\s/is','$\\1["\\2"] ',$condition);
                break;
            case 'obj':  // 识别为对象
                $condition  =   preg_replace('/\$(\w+)\.(\w+)\s/is','$\\1->\\2 ',$condition);
                break;
            default:  // 自动判断数组或对象 只支持二维
                $condition  =   preg_replace('/\$(\w+)\.(\w+)\s/is','(is_array($\\1)?$\\1["\\2"]:$\\1->\\2) ',$condition);
        }
        if(false !== strpos($condition, '$Think'))
            $condition      =   preg_replace_callback('/(\$Think.*?)\s/is', array($this, 'parseThinkVar'), $condition);        
        return $condition;
    }