business\SpecialDay::getClosestOpeningTimeBefore PHP Method

getClosestOpeningTimeBefore() public method

public getClosestOpeningTimeBefore ( Time $time, DateTime $context )
$time Time
$context DateTime
    public function getClosestOpeningTimeBefore(Time $time, \DateTime $context)
    {
        $this->evaluateOpeningIntervals($context);
        return parent::getClosestOpeningTimeBefore($time, $context);
    }

Usage Example

Beispiel #1
0
 public function testGetClosestOpeningTimeBefore()
 {
     $monday = new \DateTime('2015-05-25');
     $tuesday = new \DateTime('2015-05-26');
     $day = new SpecialDay(Days::MONDAY, function (\DateTime $date) {
         if ('2015-05-25' == $date->format('Y-m-d')) {
             return [['09:00', '14:00']];
         }
         return [['09:00', '18:00']];
     });
     $mondayClosest = $day->getClosestOpeningTimeBefore(new Time('15', '00'), $monday);
     $tuesdayClosest = $day->getClosestOpeningTimeBefore(new Time('18', '01'), $tuesday);
     $this->assertSame(14, $mondayClosest->getHours());
     $this->assertSame(0, $mondayClosest->getMinutes());
     $this->assertSame(18, $tuesdayClosest->getHours());
     $this->assertSame(0, $tuesdayClosest->getMinutes());
 }