<commit_before><?php

namespace Plummer\Calendarful\Recurrence\Type;

use Plummer\Calendarful\Recurrence\RecurrenceInterface;

class Daily implements RecurrenceInterface
{
	protected $label = 'daily';

	protected $limit = '+1 year';

	public function getLabel()
	{
		return $this->label;
	}

	public function getLimit()
	{
		return $this->limit;
	}

	public function generateOccurrences(Array $events, \DateTime $fromDate, \DateTime $toDate, $limit = null)
	{
        $return = [];

        $dailyEvents = array_filter($events, function ($event) {
            return $event->getRecurrenceType() === $this->getLabel();
        });

        foreach ($dailyEvents as $dailyEvent) {

            $startMarker = $fromDate > new \DateTime($dailyEvent->getStartDateFull())
                ? $fromDate
                : new \DateTime($dailyEvent->getStartFull());

            $endMarker = $dailyEvent->getRecurrenceUntil()
                ? min(new \DateTime($dailyEvent->getRecurrenceUntil()), $toDate)
                : $toDate;

            $dateInterval = new \DateInterval('P1D');
            $datePeriod = new \DatePeriod($startMarker, $dateInterval, $endMarker);

            foreach($datePeriod as $date) {
                $newDailyEvent = clone($dailyEvent);
                $newStartDate = $date;
                $duration = $newDailyEvent->getDuration();

                $newDailyEvent->setStartDateFull($newStartDate);
                $newStartDate->add($duration);
                $newDailyEvent->setEndDate($newStartDate);
                $newDailyEvent->setRecurrenceType();
<commit_msg>Increment the end date in the daily recurrence to accomodate for PHP's DatePeriod class not including it.<commit_after><?php

namespace Plummer\Calendarful\Recurrence\Type;

use Plummer\Calendarful\Recurrence\RecurrenceInterface;

class Daily implements RecurrenceInterface
{
	protected $label = 'daily';

	protected $limit = '+1 year';

	public function getLabel()
	{
		return $this->label;
	}

	public function getLimit()
	{
		return $this->limit;
	}

	public function generateOccurrences(Array $events, \DateTime $fromDate, \DateTime $toDate, $limit = null)
	{
        $return = [];

        $dailyEvents = array_filter($events, function ($event) {
            return $event->getRecurrenceType() === $this->getLabel();
        });

        foreach ($dailyEvents as $dailyEvent) {

            $startMarker = $fromDate > new \DateTime($dailyEvent->getStartDateFull())
                ? $fromDate
                : new \DateTime($dailyEvent->getStartFull());

            $endMarker = $dailyEvent->getRecurrenceUntil()
                ? min(new \DateTime($dailyEvent->getRecurrenceUntil()), $toDate)
                : $toDate;

            // The DatePeriod class does not actually include the end date so you have to increment it first
            $endMarker->modify('+1 day');

            $dateInterval = new \DateInterval('P1D');
            $datePeriod = new \DatePeriod($startMarker, $dateInterval, $endMarker);

            foreach($datePeriod as $date) {
                $newDailyEvent = clone($dailyEvent);
                $newStartDate = $date;
                $duration = $newDailyEvent->getDuration();

                $newDailyEvent->setStartDateFull($newStartDate);
                $newStartDate->add($duration);
                $newDailyEvent->setEndDate($newStartDate);
                $newDailyEvent->setRecurrenceType();

{'fraction_non_alphanumeric': 0.12369033760186263, 'fraction_numerical': 0.0014551804423748546, 'mean_word_length': 2.5951882845188283, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 32, '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': '900556', 'n_tokens_mistral': 1003, 'n_tokens_neox': 921, 'n_words': 199}