public function endingDailyAfterCount($count)
    {
        if (false == is_int($count) || $count <= 0) {
            throw new \InvalidArgumentException('Ending daily after count must be a positive number!');
        }

        if (null == $this->startTimeOfDay) {
            throw new \InvalidArgumentException('You must set the startDailyAt() before calling this endingDailyAfterCount()!');
        }

        $today = new \DateTime();
        $startTimeOfDayDate = $this->getTimeOfDayForDate($today, $this->startTimeOfDay);
        $maxEndTimeOfDayDate = (clone $today)->setTime(23, 59, 59);
        $remainingSecondsInDay = ((int) $maxEndTimeOfDayDate->format('U')) - ((int) $startTimeOfDayDate->format('U'));

        if ($this->intervalUnit == IntervalUnit::SECOND) {
            $intervalInSeconds = $this->interval;
        } elseif ($this->intervalUnit == IntervalUnit::MINUTE) {
            $intervalInSeconds = $this->interval * 60;
        } elseif ($this->intervalUnit == IntervalUnit::HOUR) {
            $intervalInSeconds = $this->interval * 60 * 24;
        } else {
            throw new \InvalidArgumentException(sprintf('The IntervalUnit is invalid for this trigger: "%s"', $this->intervalUnit));
        }

        if ($remainingSecondsInDay - $intervalInSeconds <= 0) {
            throw new \InvalidArgumentException('The startTimeOfDay is too late with given Interval and IntervalUnit values.');
        }

        $maxNumOfCount = ($remainingSecondsInDay / $intervalInSeconds);
        if ($count > $maxNumOfCount) {
            throw new \InvalidArgumentException(sprintf('The given count is too large!: count: "%s", max: "%s"', $count, $maxNumOfCount));
        }

        $incrementInSeconds = ($count - 1) * $intervalInSeconds;
        $endTimeOfDayDate = clone $startTimeOfDayDate;
        $endTimeOfDayDate->add(new \DateInterval(sprintf('PT%dS', $incrementInSeconds)));

        if ($endTimeOfDayDate > $maxEndTimeOfDayDate) {
            throw new \InvalidArgumentException(sprintf('The given count is too large!: count: "%s", max: "%s"', $count, $maxNumOfCount));
        }

        $this->endTimeOfDay = $endTimeOfDayDate;

        return $this;
    }
public function endingDailyAfterCount($count)
    {
        if (false == is_int($count) || $count <= 0) {
            throw new \InvalidArgumentException('Ending daily after count must be a positive number!');
        }

        if (null == $this->startTimeOfDay) {
            throw new \InvalidArgumentException('You must set the startDailyAt() before calling this endingDailyAfterCount()!');
        }

        $today = new \DateTime();
        $startTimeOfDayDate = $this->getTimeOfDayForDate($today, $this->startTimeOfDay);
        $maxEndTimeOfDayDate = (clone $today)->setTime(23, 59, 59);
        $remainingSecondsInDay = ((int) $maxEndTimeOfDayDate->format('U')) - ((int) $startTimeOfDayDate->format('U'));

        if ($this->intervalUnit == IntervalUnit::SECOND) {
            $intervalInSeconds = $this->interval;
        } elseif ($this->intervalUnit == IntervalUnit::MINUTE) {
            $intervalInSeconds = $this->interval * 60;
        } elseif ($this->intervalUnit == IntervalUnit::HOUR) {
            $intervalInSeconds = $this->interval * 60 * 24;
        } else {
            throw new \InvalidArgumentException(sprintf('The IntervalUnit is invalid for this trigger: "%s"', $this->intervalUnit));
        }

        if ($remainingSecondsInDay - $intervalInSeconds <= 0) {
            throw new \InvalidArgumentException('The startTimeOfDay is too late with given Interval and IntervalUnit values.');
        }

        $maxNumOfCount = ($remainingSecondsInDay / $intervalInSeconds);
        if ($count > $maxNumOfCount) {
            throw new \InvalidArgumentException(sprintf('The given count is too large!: count: "%s", max: "%s"', $count, $maxNumOfCount));
        }

        $incrementInSeconds = ($count - 1) * $intervalInSeconds;
        $endTimeOfDayDate = clone $startTimeOfDayDate;
        $endTimeOfDayDate->add(new \DateInterval(sprintf('PT%dS', $incrementInSeconds)));

        if ($endTimeOfDayDate > $maxEndTimeOfDayDate) {
            throw new \InvalidArgumentException(sprintf('The given count is too large!: count: "%s", max: "%s"', $count, $maxNumOfCount));
        }

        $this->endTimeOfDay = $endTimeOfDayDate;

        return $this;
    }
public function endingDailyAfterCount ( $ count ) { if ( false == is_int ( $ count ) || $ count <= 0 ) { throw new \ InvalidArgumentException ( 'Ending daily after count must be a positive number!' ) ; } if ( null == $ this -> startTimeOfDay ) { throw new \ InvalidArgumentException ( 'You must set the startDailyAt() before calling this endingDailyAfterCount()!' ) ; } $ today = new \ DateTime ( ) ; $ startTimeOfDayDate = $ this -> getTimeOfDayForDate ( $ today , $ this -> startTimeOfDay ) ; $ maxEndTimeOfDayDate = ( clone $ today ) -> setTime ( 23 , 59 , 59 ) ; $ remainingSecondsInDay = ( ( int ) $ maxEndTimeOfDayDate -> format ( 'U' ) ) - ( ( int ) $ startTimeOfDayDate -> format ( 'U' ) ) ; if ( $ this -> intervalUnit == IntervalUnit :: SECOND ) { $ intervalInSeconds = $ this -> interval ; } elseif ( $ this -> intervalUnit == IntervalUnit :: MINUTE ) { $ intervalInSeconds = $ this -> interval * 60 ; } elseif ( $ this -> intervalUnit == IntervalUnit :: HOUR ) { $ intervalInSeconds = $ this -> interval * 60 * 24 ; } else { throw new \ InvalidArgumentException ( sprintf ( 'The IntervalUnit is invalid for this trigger: "%s"' , $ this -> intervalUnit ) ) ; } if ( $ remainingSecondsInDay - $ intervalInSeconds <= 0 ) { throw new \ InvalidArgumentException ( 'The startTimeOfDay is too late with given Interval and IntervalUnit values.' ) ; } $ maxNumOfCount = ( $ remainingSecondsInDay / $ intervalInSeconds ) ; if ( $ count > $ maxNumOfCount ) { throw new \ InvalidArgumentException ( sprintf ( 'The given count is too large!: count: "%s", max: "%s"' , $ count , $ maxNumOfCount ) ) ; } $ incrementInSeconds = ( $ count - 1 ) * $ intervalInSeconds ; $ endTimeOfDayDate = clone $ startTimeOfDayDate ; $ endTimeOfDayDate -> add ( new \ DateInterval ( sprintf ( 'PT%dS' , $ incrementInSeconds ) ) ) ; if ( $ endTimeOfDayDate > $ maxEndTimeOfDayDate ) { throw new \ InvalidArgumentException ( sprintf ( 'The given count is too large!: count: "%s", max: "%s"' , $ count , $ maxNumOfCount ) ) ; } $ this -> endTimeOfDay = $ endTimeOfDayDate ; return $ this ; }
Calculate and set the endTimeOfDay using count, interval and starTimeOfDay. This means
that these must be set before this method is call.

@param int $count

@return DailyTimeIntervalScheduleBuilder
Calculate and set the endTimeOfDay using count interval and starTimeOfDay . This means that these must be set before this method is call .