@@ 596-605 (lines=10) @@ | ||
593 | ||
594 | public function asStructuredData(string $format = 'H:i', $timezone = null): array |
|
595 | { |
|
596 | $regularHours = $this->flatMap(function (OpeningHoursForDay $openingHoursForDay, string $day) use ($format, $timezone) { |
|
597 | return $openingHoursForDay->map(function (TimeRange $timeRange) use ($format, $timezone, $day) { |
|
598 | return [ |
|
599 | '@type' => 'OpeningHoursSpecification', |
|
600 | 'dayOfWeek' => ucfirst($day), |
|
601 | 'opens' => $timeRange->start()->format($format, $timezone), |
|
602 | 'closes' => $timeRange->end()->format($format, $timezone), |
|
603 | ]; |
|
604 | }); |
|
605 | }); |
|
606 | ||
607 | $exceptions = $this->flatMapExceptions(function (OpeningHoursForDay $openingHoursForDay, string $date) use ($format, $timezone) { |
|
608 | if ($openingHoursForDay->isEmpty()) { |
|
@@ 620-628 (lines=9) @@ | ||
617 | ]]; |
|
618 | } |
|
619 | ||
620 | return $openingHoursForDay->map(function (TimeRange $timeRange) use ($format, $date, $timezone) { |
|
621 | return [ |
|
622 | '@type' => 'OpeningHoursSpecification', |
|
623 | 'opens' => $timeRange->start()->format($format, $timezone), |
|
624 | 'closes' => $timeRange->end()->format($format, $timezone), |
|
625 | 'validFrom' => $date, |
|
626 | 'validThrough' => $date, |
|
627 | ]; |
|
628 | }); |
|
629 | }); |
|
630 | ||
631 | return array_merge($regularHours, $exceptions); |