protected function generate()
    {
        if ($this->subperiodsProcessed) {
            return;
        }

        parent::generate();
        $date = $this->date;

        if ($date->toString('N') > 1) {
            $date = $date->subDay($date->toString('N') - 1);
        }

        $startWeek = $date;

        $currentDay = clone $startWeek;
        while ($currentDay->compareWeek($startWeek) == 0) {
            $this->addSubperiod(new Day($currentDay));
            $currentDay = $currentDay->addDay(1);
        }
    }
protected function generate()
    {
        if ($this->subperiodsProcessed) {
            return;
        }

        parent::generate();
        $date = $this->date;

        if ($date->toString('N') > 1) {
            $date = $date->subDay($date->toString('N') - 1);
        }

        $startWeek = $date;

        $currentDay = clone $startWeek;
        while ($currentDay->compareWeek($startWeek) == 0) {
            $this->addSubperiod(new Day($currentDay));
            $currentDay = $currentDay->addDay(1);
        }
    }
protected function generate ( ) { if ( $ this -> subperiodsProcessed ) { return ; } parent :: generate ( ) ; $ date = $ this -> date ; if ( $ date -> toString ( 'N' ) > 1 ) { $ date = $ date -> subDay ( $ date -> toString ( 'N' ) - 1 ) ; } $ startWeek = $ date ; $ currentDay = clone $ startWeek ; while ( $ currentDay -> compareWeek ( $ startWeek ) == 0 ) { $ this -> addSubperiod ( new Day ( $ currentDay ) ) ; $ currentDay = $ currentDay -> addDay ( 1 ) ; } }
Generates the subperiods - one for each day in the week
Generates the subperiods - one for each day in the week