<commit_before><?php

namespace Opifer\ExpressionEngine\Constraint;

use Webmozart\Expression\Expression;
use Webmozart\Expression\Logic\Literal;

class DatePeriod extends Literal
{
    /**
     * @var string
     */
    protected $date;

    /**
     * Constructor
     *
     * @param string $period
     */
    public function __construct($date)
    {
        $this->date = $date;
    }

    /**
     * {@inheritdoc}
     */
    public function evaluate($value)
    {
        if (!$value instanceof \DatePeriod) {
            throw new \Exception('The value passed to the Date constraint should be an instance of \DateTime');
        }

        foreach ($value as $day) {
            if (strtolower($day->format($this->getDateFormat())) == strtolower($this->date)) {
                return true;
            }
        }

        return false;
    }

    /**
     * Get the date format
     *
     * @return string
     */
    protected function getDateFormat()
    {
        return 'Y-m-d';
    }

    /**
     * {@inheritdoc}
     */
    public function equivalentTo(Expression $other)
    {
        // Since this class is final, we can check with instanceof
        return $other instanceof $this;
    }
    /**
     * {@inheritdoc}
     */
    public function toString()
    {
        return 'datePeriod()';
    }
}
<commit_msg>Fixed an issue with evaluating DatePeriods<commit_after><?php

namespace Opifer\ExpressionEngine\Constraint;

use Webmozart\Expression\Expression;
use Webmozart\Expression\Logic\Literal;

class DatePeriod extends Literal
{
    /**
     * @var string
     */
    protected $date;

    /**
     * Constructor
     *
     * @param string $period
     */
    public function __construct($date)
    {
        $this->date = $date;
    }

    /**
     * {@inheritdoc}
     */
    public function evaluate($value)
    {
        if (!$value instanceof \DatePeriod) {
            throw new \Exception('The value passed to the Date constraint should be an instance of \DateTime');
        }

        foreach ($value as $day) {
            if (strtolower($day->format($this->getDateFormat())) == strtolower($this->date->format($this->getDateFormat()))) {
                return true;
            }
        }

        return false;
    }

    /**
     * Get the date format
     *
     * @return string
     */
    protected function getDateFormat()
    {
        return 'Y-m-d';
    }

    /**
     * {@inheritdoc}
     */
    public function equivalentTo(Expression $other)
    {
        // Since this class is final, we can check with instanceof
        return $other instanceof $this;
    }
    /**
     * {@inheritdoc}
     */
    public function toString()
    {
        return 'datePeriod()';
    }
}

{'fraction_non_alphanumeric': 0.12202271894466837, 'fraction_numerical': 0.0, 'mean_word_length': 1.84375, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '2758786', 'n_tokens_mistral': 774, 'n_tokens_neox': 768, 'n_words': 193}