@@ 688-697 (lines=10) @@ | ||
685 | ||
686 | public function asStructuredData(string $format = 'H:i', $timezone = null): array |
|
687 | { |
|
688 | $regularHours = $this->flatMap(function (OpeningHoursForDay $openingHoursForDay, string $day) use ($format, $timezone) { |
|
689 | return $openingHoursForDay->map(function (TimeRange $timeRange) use ($format, $timezone, $day) { |
|
690 | return [ |
|
691 | '@type' => 'OpeningHoursSpecification', |
|
692 | 'dayOfWeek' => ucfirst($day), |
|
693 | 'opens' => $timeRange->start()->format($format, $timezone), |
|
694 | 'closes' => $timeRange->end()->format($format, $timezone), |
|
695 | ]; |
|
696 | }); |
|
697 | }); |
|
698 | ||
699 | $exceptions = $this->flatMapExceptions(function (OpeningHoursForDay $openingHoursForDay, string $date) use ($format, $timezone) { |
|
700 | if ($openingHoursForDay->isEmpty()) { |
|
@@ 712-720 (lines=9) @@ | ||
709 | ]]; |
|
710 | } |
|
711 | ||
712 | return $openingHoursForDay->map(function (TimeRange $timeRange) use ($format, $date, $timezone) { |
|
713 | return [ |
|
714 | '@type' => 'OpeningHoursSpecification', |
|
715 | 'opens' => $timeRange->start()->format($format, $timezone), |
|
716 | 'closes' => $timeRange->end()->format($format, $timezone), |
|
717 | 'validFrom' => $date, |
|
718 | 'validThrough' => $date, |
|
719 | ]; |
|
720 | }); |
|
721 | }); |
|
722 | ||
723 | return array_merge($regularHours, $exceptions); |