<commit_before><?php

namespace LumengPHP\Db\Condition;

use LumengPHP\Db\Exceptions\InvalidSQLConditionException;

/**
 * 接受一个关联数组
 *
 * @author Lumeng <<EMAIL>>
 */
class ArrayCondition extends CompositeCondition {

    /**
     * @var array 子条件数组，是一个关联数组
     */
    protected $conditions;

    public function __construct(array $conditions) {
        $this->conditions = $conditions;
    }

    public function parse() {
        return $this->parseArrayCondition($this->conditions);
    }

    private function parseArrayCondition($arrayCondition) {
        $parsedConditions = [];

        $logic = 'AND';
        foreach ($arrayCondition as $field => $value) {
            //同一级条件下同一个字段出现多次
            if (strpos($field, '#')) {
                list($field, ) = explode('#', $field);
            }

            //如果不是操作符，是普通的条件
            if ($field[0] != '_') {
                $parsedConditions[] = $this->parseSimpleCondition($field, $value);
                continue;
            }

            /*
             * 如果是操作符
             */

            $op = $field;
            $operand = $value;<commit_msg>设计新的查询语言<commit_after><?php

namespace LumengPHP\Db\Condition;

use LumengPHP\Db\Exceptions\InvalidSQLConditionException;

/**
 * 接受一个关联数组
 *
 * @author Lumeng <<EMAIL>>
 */
class ArrayCondition extends CompositeCondition {

    /**
     * @var array 子条件数组，是一个关联数组
     */
    protected $conditions;

    public function __construct(array $conditions) {
        $this->conditions = $conditions;
    }

    public function parse() {
        return $this->parseArrayCondition($this->conditions);
    }

    private function parseArrayCondition($arrayCondition) {
        $parsedConditions = [];

        $logic = 'AND';
        foreach ($arrayCondition as $field => $value) {
            //如果不是操作符，是普通的条件
            if ($field[0] != '_') {
                if (is_array($value) && !isset($value[0])) {
                    
                } else {
                    $parsedConditions[] = $this->parseSimpleCondition($field, $value);
                }
                continue;
            }

            /*
             * 如果是操作符
             */

            $op = $field;
            $operand = $value;
{'fraction_non_alphanumeric': 0.1302388463271744, 'fraction_numerical': 0.0013519603424966202, 'mean_word_length': 1.8136882129277567, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4033697', 'n_tokens_mistral': 683, 'n_tokens_neox': 670, 'n_words': 113}