private function getClosestDateIntervalBefore(\DateTime $date): DateTimeInterval
    {
        $tmpDate = clone $date;
        $dayOfWeek = (int)$tmpDate->format('N');
        $time = TimeBuilder::fromDate($tmpDate);

        if (null !== $day = $this->getDay($dayOfWeek)) {
            if (null !== $closestTime = $day->getClosestPreviousOpeningHoursInterval($time)) {
                return $this->buildDateTimeInterval($tmpDate, $closestTime);
            }
        }

        $tmpDate = $this->getDateBefore($tmpDate);

        $closestDay = $this->getClosestDayBefore((int)$tmpDate->format('N'));

        $closingTime = $closestDay->getClosingTime();
        $closestTime = $closestDay->getClosestPreviousOpeningHoursInterval($closingTime);

        return $this->buildDateTimeInterval($tmpDate, $closestTime);
    }
private function getClosestDateIntervalBefore(\DateTime $date): DateTimeInterval
    {
        $tmpDate = clone $date;
        $dayOfWeek = (int)$tmpDate->format('N');
        $time = TimeBuilder::fromDate($tmpDate);

        if (null !== $day = $this->getDay($dayOfWeek)) {
            if (null !== $closestTime = $day->getClosestPreviousOpeningHoursInterval($time)) {
                return $this->buildDateTimeInterval($tmpDate, $closestTime);
            }
        }

        $tmpDate = $this->getDateBefore($tmpDate);

        $closestDay = $this->getClosestDayBefore((int)$tmpDate->format('N'));

        $closingTime = $closestDay->getClosingTime();
        $closestTime = $closestDay->getClosestPreviousOpeningHoursInterval($closingTime);

        return $this->buildDateTimeInterval($tmpDate, $closestTime);
    }
private function getClosestDateIntervalBefore ( \ DateTime $ date ) : DateTimeInterval { $ tmpDate = clone $ date ; $ dayOfWeek = ( int ) $ tmpDate -> format ( 'N' ) ; $ time = TimeBuilder :: fromDate ( $ tmpDate ) ; if ( null !== $ day = $ this -> getDay ( $ dayOfWeek ) ) { if ( null !== $ closestTime = $ day -> getClosestPreviousOpeningHoursInterval ( $ time ) ) { return $ this -> buildDateTimeInterval ( $ tmpDate , $ closestTime ) ; } } $ tmpDate = $ this -> getDateBefore ( $ tmpDate ) ; $ closestDay = $ this -> getClosestDayBefore ( ( int ) $ tmpDate -> format ( 'N' ) ) ; $ closingTime = $ closestDay -> getClosingTime ( ) ; $ closestTime = $ closestDay -> getClosestPreviousOpeningHoursInterval ( $ closingTime ) ; return $ this -> buildDateTimeInterval ( $ tmpDate , $ closestTime ) ; }
Get the closest business hours date interval before the given date.

@param \DateTime $date The given date.
@return DateTimeInterval
Get the closest business hours date interval before the given date .