@param \Closure|EventHandlerInterface|string $handler
@param \Closure|EventHandlerInterface|string $condition

@return \EasyWeChat\Kernel\Clauses\Clause

@throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
@throws \ReflectionException
559373
public function push($handler, $condition = '*')
    {
        list($handler, $condition) = $this->resolveHandlerAndCondition($handler, $condition);

        if (!isset($this->handlers[$condition])) {
            $this->handlers[$condition] = [];
        }

        array_push($this->handlers[$condition], $handler);

        return $this->newClause($handler);
    }
511821
public function join($source, $condition){
		if($this->validateConditions())
			return $this;

		if(!(is_string($source) || $source instanceof self || $source instanceof Literal))
			throw new InvalidArgumentException('Argument 1 must be a string, Neevo\\Literal or Neevo\\Result.');
		if(!(is_string($condition) || $condition instanceof Literal))
			throw new InvalidArgumentException('Argument 2 must be a string or Neevo\\Literal.');

		if($source instanceof self)
			$this->subqueries[] = $source;

		$this->resetState();
		$type = (func_num_args() > 2) ? func_get_arg(2) : '';

		$this->joins[] = array($source, $condition, $type);

		return $this;
	}
206880
public function setConditionMode(string $conditionMode)
    {
        if (!in_array($conditionMode, [self::CONDITION_MODE_AND, self::CONDITION_MODE_OR], true)) {
            throw Exception\InvalidArgumentException::format(
                'Invalid condition mode supplied to %s: expecting one of (%s), \'%s\' given',
                __METHOD__, Debug::formatValues([self::CONDITION_MODE_AND, self::CONDITION_MODE_OR]), $conditionMode
            );
        }

        $this->conditionMode = $conditionMode;

        return $this;
    }
1331123
public function parse(ActivationInterface $condition)
    {
        $rootNode = null;
        $this->resetParser($condition);

        if (false === $condition instanceof EmptyActivation) {
            try {
                $rootNode = $this->getNodeRecursive();
            } catch (ConditionParserException $exception) {
                $error = new Error($exception->getMessage(), $exception->getCode());
                $this->result->addError($error);
            }
        }

        $rootNode = $rootNode ?: NullNode::get();

        /** @var ConditionTree $tree */
        $tree = GeneralUtility::makeInstance(ConditionTree::class, $rootNode, $this->result);

        return $tree;
    }
121524
protected function _evaluateCondition($condition, Event $event)
    {
        if (!isset($this->_options[$condition])) {
            return $condition !== 'unless';
        }
        if (!is_callable($this->_options[$condition])) {
            throw new RuntimeException(self::class . ' the `' . $condition . '` condition is not a callable!');
        }

        return $this->_options[$condition]($event);
    }
422274
public function where($condition, $value = null, $type = null)
    {

        switch ($type) {
            case null:
                $clause = 'WHERE';
                break;
            case 'or':
                $clause = 'OR';
                break;
            case 'and':
                $clause = 'AND';
                break;
            default:
                $clause = 'WHERE';
        }

        $this->oosql_where .= " $clause $condition";

        if ($value instanceof oosql) {

            $this->oosql_where .= $value->getSql();
        } elseif (null !== $value) {

            $this->oosql_conValues[] = $value;
        }

        return $this;
    }
1079909
public function setCondition($condition)
    {
        if ($condition === null) {
            $this->condition = $condition;
            return $this;
        }

        if (!is_string($condition)) {
            throw new InvalidArgumentException(
                'Custom expression must be a string.'
            );
        }

        $condition = trim($condition);
        if ($condition === '') {
            $condition = null;
        }

        $this->condition = $condition;
        return $this;
    }
1303004
protected function addConditions($query, $conditions)
    {
        foreach ($conditions as $key => $value) {
            if ($value instanceof Closure) {
                $query->where(function ($query) use ($value) {
                    $value($query);
                });
            } else {
                $this->addWhere($query, $key, $value);
            }
        }

        return $query;
    }
179370
public function where(string ...$condition) : self
    {
        // We want to wipe out anything already in the condition list
        $this->whereConditions = [];
        $this->whereConditions = $this->addConditionToClause(
            $this->whereConditions, 'AND', ...$condition);

        return $this;
    }
12274
public function getPreconditionByHandle($handle)
    {
        $list = $this->config->get('install.preconditions');
        if (!isset($list[$handle])) {
            throw new Exception(sprintf('Unable to find an install precondition with handle %s', $handle));
        }
        if (!$list[$handle]) {
            throw new Exception(sprintf('The precondition with handle %s is disabled', $handle));
        }
        $className = $list[$handle];
        $instance = $this->getPreconditionByClassName($className);

        return $instance;
    }
140169
public function updateCondition(Condition $condition): void
    {
        $query = $this->connection->createQueryBuilder();
        $query
            ->update('ngbm_rule_condition')
            ->set('rule_id', ':rule_id')
            ->set('type', ':type')
            ->set('value', ':value')
            ->where(
                $query->expr()->eq('id', ':id')
            )
            ->setParameter('id', $condition->id, Type::INTEGER)
            ->setParameter('rule_id', $condition->ruleId, Type::INTEGER)
            ->setParameter('type', $condition->type, Type::STRING)
            ->setParameter('value', json_encode($condition->value), Type::STRING);

        $this->applyStatusCondition($query, $condition->status);

        $query->execute();
    }
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]);
    }
44494
protected function parseCondition($condition)
    {
        $tableAlias = $this->getAlias();
        $parts = [];

        if ($condition instanceof QueryBuilderAwareInterface) {
            $condition->setQueryBuilder($this);
        }

        if ($condition instanceof Expression) {
            $parts[] = $this->getAdapter()->quoteSql($condition->toSQL());
        } elseif ($condition instanceof Q) {
            $condition->setLookupBuilder($this->getLookupBuilder());
            $condition->setAdapter($this->getAdapter());
            $condition->setTableAlias($tableAlias);
            $parts[] = $condition->toSQL();
        } elseif ($condition instanceof ToSqlInterface) {
            $parts[] = $condition->toSQL();
        } elseif (is_array($condition)) {
            foreach ($condition as $key => $value) {
                if ($value instanceof Q) {
                    $parts[] = $this->parseCondition($value);
                } else {
                    list($lookup, $column, $lookupValue) = $this->lookupBuilder->parseLookup($this, $key, $value);
                    $column = $this->getLookupBuilder()->fetchColumnName($column);
                    if (false === empty($tableAlias) && false === strpos($column, '.')) {
                        $column = $tableAlias.'.'.$column;
                    }
                    $parts[] = $this->lookupBuilder->runLookup($this->getAdapter(), $lookup, $column, $lookupValue);
                }
            }
        } elseif (is_string($condition)) {
            $parts[] = $condition;
        } elseif ($condition instanceof Expression) {
            $parts[] = $condition->toSQL();
        }

        if (1 === count($parts)) {
            return $parts[0];
        }

        return '('.implode(') AND (', $parts).')';
    }
612789
public function addCondition(Condition $condition): Condition
    {
        $query = $this->connection->createQueryBuilder()
            ->insert('ngbm_rule_condition')
            ->values(
                [
                    'id' => ':id',
                    'status' => ':status',
                    'rule_id' => ':rule_id',
                    'type' => ':type',
                    'value' => ':value',
                ]
            )
            ->setValue(
                'id',
                $condition->id !== null ?
                    (int) $condition->id :
                    $this->connectionHelper->getAutoIncrementValue('ngbm_rule_condition')
            )
            ->setParameter('status', $condition->status, Type::INTEGER)
            ->setParameter('rule_id', $condition->ruleId, Type::INTEGER)
            ->setParameter('type', $condition->type, Type::STRING)
            ->setParameter('value', json_encode($condition->value), Type::STRING);

        $query->execute();

        $condition->id = $condition->id ?? (int) $this->connectionHelper->lastInsertId('ngbm_rule_condition');

        return $condition;
    }
1205198
protected function makeClosure($handler)
    {
        if (is_callable($handler)) {
            return $handler;
        }

        if (is_string($handler)) {
            if (!class_exists($handler)) {
                throw new InvalidArgumentException(sprintf('Class "%s" not exists.', $handler));
            }

            if (!in_array(EventHandlerInterface::class, (new \ReflectionClass($handler))->getInterfaceNames(), true)) {
                throw new InvalidArgumentException(sprintf('Class "%s" not an instance of "%s".', $handler, EventHandlerInterface::class));
            }

            return function ($payload) use ($handler) {
                return (new $handler($this->app ?? null))->handle($payload);
            };
        }

        if ($handler instanceof EventHandlerInterface) {
            return function () use ($handler) {
                return $handler->handle(...func_get_args());
            };
        }

        throw new InvalidArgumentException('No valid handler is found in arguments.');
    }
1271372
public function unshift($handler, $condition = '*')
    {
        list($handler, $condition) = $this->resolveHandlerAndCondition($handler, $condition);

        if (!isset($this->handlers[$condition])) {
            $this->handlers[$condition] = [];
        }

        array_unshift($this->handlers[$condition], $handler);

        return $this->newClause($handler);
    }
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 );
	}