<commit_before><?php
namespace Search\Model\Filter;

use Cake\Database\Expression\QueryExpression;

class Value extends Base
{

    /**
     * Default configuration.
     *
     * @var array
     */
    protected $_defaultConfig = [
        'mode' => 'OR'
    ];

    /**
     * Process a value condition ($x == $y).
     *
     * @return bool
     */
    public function process()
    {
        $value = $this->value();
        if ($value === null) {
            return false;
        }

        $isMultiValue = is_array($value);
        if ($isMultiValue &&
            empty($value)
        ) {
            return false;
        }

        $expressions = [];
        foreach ($this->fields() as $field) {
            $expressions[] = function (QueryExpression $e) use ($field, $value, $isMultiValue) {
                if ($isMultiValue) {
                    return $e->in($field, $value);
                }

                return $e->eq($field, $value);
            };
        }

        if (!empty($expressions)) {
            $this->getQuery()->andWhere([$this->config('mode') => $expressions]);
        }

        return true;
    }
}<commit_msg>refactor: rely on expression validation instead of an empty check<commit_after><?php
namespace Search\Model\Filter;

use Cake\Database\Expression\QueryExpression;

class Value extends Base
{

    /**
     * Default configuration.
     *
     * @var array
     */
    protected $_defaultConfig = [
        'mode' => 'OR'
    ];

    /**
     * Process a value condition ($x == $y).
     *
     * @return bool
     */
    public function process()
    {
        $value = $this->value();
        if ($value === null) {
            return false;
        }

        $isMultiValue = is_array($value);
        if ($isMultiValue &&
            empty($value)
        ) {
            return false;
        }

        $expressions = [];
        foreach ($this->fields() as $field) {
            $expressions[] = function (QueryExpression $e) use ($field, $value, $isMultiValue) {
                if ($isMultiValue) {
                    return $e->in($field, $value);
                }

                return $e->eq($field, $value);
            };
        }

        $this->getQuery()->andWhere([$this->config('mode') => $expressions]);

        return true;
    }
}
{'fraction_non_alphanumeric': 0.1484848484848485, 'fraction_numerical': 0.0, 'mean_word_length': 1.5792410714285714, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '4091148', 'n_tokens_mistral': 659, 'n_tokens_neox': 635, 'n_words': 145}