@@ 473-492 (lines=20) @@ | ||
470 | $previousOpen = $openingHoursForDay->previousOpen(Time::fromDateTime($dateTime)); |
|
471 | $tries = $this->getDayLimit(); |
|
472 | ||
473 | while ($previousOpen === false || ($previousOpen->hours() === 0 && $previousOpen->minutes() === 0)) { |
|
474 | if (--$tries < 0) { |
|
475 | throw MaximumLimitExceeded::forString( |
|
476 | 'No open date/time found in the previous '.$this->getDayLimit().' days,'. |
|
477 | ' use $openingHours->setDayLimit() to increase the limit.' |
|
478 | ); |
|
479 | } |
|
480 | ||
481 | $midnight = $dateTime->setTime(0, 0, 0); |
|
482 | $dateTime = clone $midnight; |
|
483 | $dateTime = $dateTime->modify('-1 minute'); |
|
484 | ||
485 | $openingHoursForDay = $this->forDate($dateTime); |
|
486 | ||
487 | if ($this->isOpenAt($midnight) && ! $openingHoursForDay->isOpenAt(Time::fromString('23:59'))) { |
|
488 | return $midnight; |
|
489 | } |
|
490 | ||
491 | $previousOpen = $openingHoursForDay->previousOpen(Time::fromDateTime($dateTime)); |
|
492 | } |
|
493 | ||
494 | $nextDateTime = $previousOpen->toDateTime(); |
|
495 | ||
@@ 518-536 (lines=19) @@ | ||
515 | ||
516 | $tries = $this->getDayLimit(); |
|
517 | ||
518 | while ($previousClose === false || ($previousClose->hours() === 0 && $previousClose->minutes() === 0)) { |
|
519 | if (--$tries < 0) { |
|
520 | throw MaximumLimitExceeded::forString( |
|
521 | 'No close date/time found in the previous '.$this->getDayLimit().' days,'. |
|
522 | ' use $openingHours->setDayLimit() to increase the limit.' |
|
523 | ); |
|
524 | } |
|
525 | ||
526 | $midnight = $dateTime->setTime(0, 0, 0); |
|
527 | $dateTime = clone $midnight; |
|
528 | $dateTime = $dateTime->modify('-1 minute'); |
|
529 | $openingHoursForDay = $this->forDate($dateTime); |
|
530 | ||
531 | if ($this->isClosedAt($midnight) && $openingHoursForDay->isOpenAt(Time::fromString('23:59'))) { |
|
532 | return $midnight; |
|
533 | } |
|
534 | ||
535 | $previousClose = $openingHoursForDay->previousClose(Time::fromDateTime($dateTime)); |
|
536 | } |
|
537 | ||
538 | $previousDateTime = $previousClose->toDateTime(); |
|
539 |