/** * @covers ::__construct * @covers ::getFrom * @covers ::getTo */ public function testConstruct() { $from = new DateTime('2014-12-01'); $to = new DateTime('2016-03-02'); $span = new DateTimeSpan($from, $to); $this->assertSame($from, $span->getFrom()); $this->assertSame($to, $span->getTo()); }
/** * @param DateTimeSpan $span * @param DateTime $start_date * @return DateTimeSpan */ public function extendBusinessDateTimeSpan(DateTimeSpan $span, DateTime $start_date = null) { $from = clone $span->getFrom(); $to = clone $span->getTo(); foreach ($this->dates as $holiday) { if ($start_date and $holiday < $start_date or 5 < $holiday->format('N')) { continue; } if ($holiday <= $from) { $from->modify('+1 weekday'); } if ($holiday <= $to) { $to->modify('+1 weekday'); } } return new DateTimeSpan($from, $to); }