<commit_before><?php

declare(strict_types=1);

namespace Psi\Component\Grid\Filter;

use Psi\Component\ObjectAgent\Query\Comparison;
use Psi\Component\ObjectAgent\Query\Expression;
use Psi\Component\ObjectAgent\Query\Query;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class DateFilter extends AbstractComparatorFilter
{
    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('apply', CheckboxType::class, []);
        $this->addComparatorChoice($builder, $options);
        $builder->add('value', DateType::class, []);
    }

    /**
     * {@inheritdoc}
     */
    public function getExpression(string $fieldName, array $data): Expression
    {
        $comparator = $data['comparator'] ?: Comparison::EQUALS;

        return Query::comparison(
            $comparator,
            $fieldName,
            $data['value']
        );
    }

    /**
     * {@inheritdoc}
     */
    public function isApplicable(array $filterData): bool
    {
        return (bool) $filterData['apply'];
    }

    /**
     * {@inheritdoc}
     */
    public function configureOptions(OptionsResolver $options)
    {
        $options->setDefault('comparators', $this->getComparatorMap());
    }

    protected function getComparatorMap(): array
    {
        $supported = [
            Comparison::EQUALS,
            Comparison::NOT_EQUALS,
            Comparison::GREATER_THAN,
            Comparison::GREATER_THAN_EQUAL,
            Comparison::LESS_THAN_EQUAL,
            Comparison::LESS_THAN,
        ];

        return array_combine($supported, $supported);
    }
}
<commit_msg>Apply checkbox not mandatory for date<commit_after><?php

declare(strict_types=1);

namespace Psi\Component\Grid\Filter;

use Psi\Component\ObjectAgent\Query\Comparison;
use Psi\Component\ObjectAgent\Query\Expression;
use Psi\Component\ObjectAgent\Query\Query;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class DateFilter extends AbstractComparatorFilter
{
    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('apply', CheckboxType::class, [
            'required' => false,
        ]);
        $this->addComparatorChoice($builder, $options);
        $builder->add('value', DateType::class, []);
    }

    /**
     * {@inheritdoc}
     */
    public function getExpression(string $fieldName, array $data): Expression
    {
        $comparator = $data['comparator'] ?: Comparison::EQUALS;

        return Query::comparison(
            $comparator,
            $fieldName,
            $data['value']
        );
    }

    /**
     * {@inheritdoc}
     */
    public function isApplicable(array $filterData): bool
    {
        return (bool) $filterData['apply'];
    }

    /**
     * {@inheritdoc}
     */
    public function configureOptions(OptionsResolver $options)
    {
        $options->setDefault('comparators', $this->getComparatorMap());
    }

    protected function getComparatorMap(): array
    {
        $supported = [
            Comparison::EQUALS,
            Comparison::NOT_EQUALS,
            Comparison::GREATER_THAN,
            Comparison::GREATER_THAN_EQUAL,
            Comparison::LESS_THAN_EQUAL,
            Comparison::LESS_THAN,
        ];

        return array_combine($supported, $supported);
    }
}

{'fraction_non_alphanumeric': 0.12607066381156318, 'fraction_numerical': 0.0005353319057815846, 'mean_word_length': 2.7671370967741935, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, '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': '5077406', 'n_tokens_mistral': 1075, 'n_tokens_neox': 1059, 'n_words': 169}