@@ 674-683 (lines=10) @@ | ||
671 | ||
672 | public function asStructuredData(string $format = 'H:i', $timezone = null): array |
|
673 | { |
|
674 | $regularHours = $this->flatMap(function (OpeningHoursForDay $openingHoursForDay, string $day) use ($format, $timezone) { |
|
675 | return $openingHoursForDay->map(function (TimeRange $timeRange) use ($format, $timezone, $day) { |
|
676 | return [ |
|
677 | '@type' => 'OpeningHoursSpecification', |
|
678 | 'dayOfWeek' => ucfirst($day), |
|
679 | 'opens' => $timeRange->start()->format($format, $timezone), |
|
680 | 'closes' => $timeRange->end()->format($format, $timezone), |
|
681 | ]; |
|
682 | }); |
|
683 | }); |
|
684 | ||
685 | $exceptions = $this->flatMapExceptions(function (OpeningHoursForDay $openingHoursForDay, string $date) use ($format, $timezone) { |
|
686 | if ($openingHoursForDay->isEmpty()) { |
|
@@ 698-706 (lines=9) @@ | ||
695 | ]]; |
|
696 | } |
|
697 | ||
698 | return $openingHoursForDay->map(function (TimeRange $timeRange) use ($format, $date, $timezone) { |
|
699 | return [ |
|
700 | '@type' => 'OpeningHoursSpecification', |
|
701 | 'opens' => $timeRange->start()->format($format, $timezone), |
|
702 | 'closes' => $timeRange->end()->format($format, $timezone), |
|
703 | 'validFrom' => $date, |
|
704 | 'validThrough' => $date, |
|
705 | ]; |
|
706 | }); |
|
707 | }); |
|
708 | ||
709 | return array_merge($regularHours, $exceptions); |