<commit_before><?php
namespace Riesenia\Utility\Condition;

/**
 * This class will enable to provide configuration for two independent “prefixes”.
 *
 * Constructor accepts configuration array in format:
 *     'prefix' => [
 *         'placeholder' => [
 *             'field' => 'field name',
 *             'operators' => [available operators]
 *         ]
 *     ]
 *
 * @author <NAME> <<EMAIL>>
 */
class QueryEvaluatorTwofold extends QueryEvaluator
{
    /**
     * Setup
     *
     * @param array configuration options
     */
    public function __construct(array $config)
    {
        if (!is_array($config) or count($config) == 0) {
            throw new QueryEvaluatorException('Invalid config format', QueryEvaluatorException::MISSING_CONFIG_FORMAT);
        }

        $this->_config = $config;
    }

    /**
     * Parse condition (column operator value)
     *
     * @param string condition
     * @return array
     */
    public function parseCondition($condition)
    {
        $condition = array_map('trim', explode(' ', $condition, 3));

        if (count($condition) < 3) {
            throw new QueryEvaluatorException(['placeholder' => $condition[0]], QueryEvaluatorException::INVALID_CONDITION);
        }

        list($column, $operator, $value) = $condition;

        // check if field has a prefix
        if (strpos($column, '.') !== false) {
            list($prefix, $column) = explode('.', $column);

            if (!isset($this->_config[$prefix][$column])) {
                throw new QueryEvaluatorException(['placeholder' => "{$prefix}.{$column}"], QueryEvaluatorException::UNKNOWN_PLACEHOLDER);
            }

            if (!in_array($operator, $this->_config[$prefix][$column]['operators'])) {
                throw new QueryEvaluatorException(['placeholder' => "{$prefix}.{$column}", 'operator' => $operator], QueryEvaluatorException::UNKNOWN_OPERATOR);
            }

            $parsedCondition = $this->_parseCondition($prefix.".".$this->_config[$prefix][$column]['field'], $operator, $value);
        } else {
            throw new QueryEvaluatorException(['placeholder' => $column], QueryEvaluatorException::MISSING_PREFIX);
        }

        return $parsedCondition;
    }
}<commit_msg>added space in between dots<commit_after><?php
namespace Riesenia\Utility\Condition;

/**
 * This class will enable to provide configuration for two independent “prefixes”.
 *
 * Constructor accepts configuration array in format:
 *     'prefix' => [
 *         'placeholder' => [
 *             'field' => 'field name',
 *             'operators' => [available operators]
 *         ]
 *     ]
 *
 * @author <NAME> <<EMAIL>>
 */
class QueryEvaluatorTwofold extends QueryEvaluator
{
    /**
     * Setup
     *
     * @param array configuration options
     */
    public function __construct(array $config)
    {
        if (!is_array($config) or count($config) == 0) {
            throw new QueryEvaluatorException('Invalid config format', QueryEvaluatorException::MISSING_CONFIG_FORMAT);
        }

        $this->_config = $config;
    }

    /**
     * Parse condition (column operator value)
     *
     * @param string condition
     * @return array
     */
    public function parseCondition($condition)
    {
        $condition = array_map('trim', explode(' ', $condition, 3));

        if (count($condition) < 3) {
            throw new QueryEvaluatorException(['placeholder' => $condition[0]], QueryEvaluatorException::INVALID_CONDITION);
        }

        list($column, $operator, $value) = $condition;

        // check if field has a prefix
        if (strpos($column, '.') !== false) {
            list($prefix, $column) = explode('.', $column);

            if (!isset($this->_config[$prefix][$column])) {
                throw new QueryEvaluatorException(['placeholder' => "{$prefix}.{$column}"], QueryEvaluatorException::UNKNOWN_PLACEHOLDER);
            }

            if (!in_array($operator, $this->_config[$prefix][$column]['operators'])) {
                throw new QueryEvaluatorException(['placeholder' => "{$prefix}.{$column}", 'operator' => $operator], QueryEvaluatorException::UNKNOWN_OPERATOR);
            }

            $parsedCondition = $this->_parseCondition($prefix . "." . $this->_config[$prefix][$column]['field'], $operator, $value);
        } else {
            throw new QueryEvaluatorException(['placeholder' => $column], QueryEvaluatorException::MISSING_PREFIX);
        }

        return $parsedCondition;
    }
}
{'fraction_non_alphanumeric': 0.14813167259786478, 'fraction_numerical': 0.0017793594306049821, 'mean_word_length': 2.7196029776674937, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 37, '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': '1675399', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1190, 'n_words': 263}