/** * Calendrier constructor. * * Génère chaque jours du calendrier pour une période scolaire donnée * * @param PeriodInterface $period * @param function - $closureIsDayOff */ public function __construct(PeriodInterface $yearPeriod, $closureIsDayOff) { $this->yearPeriod = $yearPeriod; $this->days = array(); $period = new Period($this->yearPeriod->getFirstDate(), new \DateTimeImmutable($this->yearPeriod->getLastDate()->format('Y-m') . '-31')); foreach ($period->getDayIterator() as $currentDay) { $d = new Day($currentDay); $d->setOff($closureIsDayOff($d)); if (!$yearPeriod->isIncluded($d->getDate())) { $d->setOff(true); } $this->days[$d->getMonth()][$d->getDay()] = $d; } }
/** * @covers ::setOff */ public function testSetOffChangeIsOff() { $day = new Day(new \DateTime('2016-01-01')); $day->setOff(true); $this->assertTrue($day->isOff()); $day->setOff(false); $this->assertFalse($day->isOff()); }