League\Period\Period::split PHP Méthode

split() public méthode

The interval can be
  • a DateInterval object
  • an int interpreted as the duration expressed in seconds.
  • a string in a format supported by DateInterval::createFromDateString
public split ( DateInterva\DateInterval | integer | string $interval ) : Generator
$interval DateInterva\DateInterval | integer | string The interval
Résultat Generator
    public function split($interval)
    {
        $startDate = $this->startDate;
        $interval = static::filterDateInterval($interval);
        do {
            $endDate = $startDate->add($interval);
            if ($endDate > $this->endDate) {
                $endDate = $this->endDate;
            }
            (yield new static($startDate, $endDate));
            $startDate = $endDate;
        } while ($startDate < $this->endDate);
    }