<commit_before><?php

namespace Kunstmaan\AdminListBundle\AdminList\FilterType\ORM;

use DateTime;
use Symfony\Component\HttpFoundation\Request;

/**
 * DateTimeFilterType.
 */
class DateTimeFilterType extends AbstractORMFilterType
{
    /**
     * @param Request $request  The request
     * @param array   &$data    The data
     * @param string  $uniqueId The unique identifier
     */
    public function bindRequest(Request $request, array &$data, $uniqueId)
    {
        $data['comparator'] = $request->query->get('filter_comparator_'.$uniqueId);
        $data['value'] = $request->query->get('filter_value_'.$uniqueId);
    }

    /**
     * @param array  $data     The data
     * @param string $uniqueId The unique identifier
     */
    public function apply(array $data, $uniqueId)
    {
        if (isset($data['value']) && isset($data['comparator'])) {
            /** @var DateTime $datetime */
            $date = empty($data['value']['date']) ? date('d/m/Y') : $data['value']['date'];
            $time = empty($data['value']['time']) ? date('H:i') : $data['value']['time'];
            $dateTime = DateTime::createFromFormat('d/m/Y H:i', $date.' '.$time);

            if (false === $dateTime) {
                // Failed to create DateTime object.
                return;
            }
            switch ($data['comparator']) {
                case 'before':
                    $this->queryBuilder->andWhere($this->queryBuilder->expr()->lte($this->getAlias().$this->columnName, ':var_'.$uniqueId));

                    break;
                case 'after':
                    $this->queryBuilder->andWhere($this->queryBuilder->expr()->gt($this->getAlias().$this->columnName, ':var_'.$uniqueId));

                    break;
            }
            $this->queryBuilder->setParameter('var_'.$uniqueId, $dateTime->format('Y-m-d H:i'));
        }
    }

    /**
     * @return string
     */
    public function getTemplate()
    {
        return 'KunstmaanAdminListBundle:FilterType:dateTimeFilter.html.twig';
    }
}<commit_msg>Update DateTimeFilterType.php<commit_after><?php

namespace Kunstmaan\AdminListBundle\AdminList\FilterType\ORM;

use DateTime;
use Symfony\Component\HttpFoundation\Request;

/**
 * DateTimeFilterType.
 */
class DateTimeFilterType extends AbstractORMFilterType
{
    /**
     * @param Request $request  The request
     * @param array   &$data    The data
     * @param string  $uniqueId The unique identifier
     */
    public function bindRequest(Request $request, array &$data, $uniqueId)
    {
        $data['comparator'] = $request->query->get('filter_comparator_'.$uniqueId);
        $data['value'] = $request->query->get('filter_value_'.$uniqueId);
    }

    /**
     * @param array  $data     The data
     * @param string $uniqueId The unique identifier
     */
    public function apply(array $data, $uniqueId)
    {
        if (isset($data['value']) && isset($data['comparator'])) {
            /** @var DateTime $datetime */
            $date = empty($data['value']['date']) ? date('d/m/Y') : $data['value']['date'];
            $time = empty($data['value']['time']) ? date('H:i') : $data['value']['time'];
            $dateTime = DateTime::createFromFormat('d/m/Y H:i', $date.' '.$time);

            if (false === $dateTime) {
                // Failed to create DateTime object.
                return;
            }
            
            $colName = stripos($this->columnName,'.') === false ? $this->getAlias().$this->columnName : $this->columnName;
            
            switch ($data['comparator']) {
                case 'before':
                    $this->queryBuilder->andWhere($this->queryBuilder->expr()->lte($colName, ':var_'.$uniqueId));

                    break;
                case 'after':
                    $this->queryBuilder->andWhere($this->queryBuilder->expr()->gt($colName, ':var_'.$uniqueId));

                    break;
            }
            $this->queryBuilder->setParameter('var_'.$uniqueId, $dateTime->format('Y-m-d H:i'));
        }
    }

    /**
     * @return string
     */
    public function getTemplate()
    {
        return 'KunstmaanAdminListBundle:FilterType:dateTimeFilter.html.twig';
    }
}
{'fraction_non_alphanumeric': 0.1686060318214201, 'fraction_numerical': 0.0, 'mean_word_length': 2.300940438871473, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, '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': '7062271', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1195, 'n_words': 216}