@@ 526-535 (lines=10) @@ | ||
523 | ||
524 | public function asStructuredData(): array |
|
525 | { |
|
526 | $regularHours = $this->flatMap(function (OpeningHoursForDay $openingHoursForDay, string $day) { |
|
527 | return $openingHoursForDay->map(function (TimeRange $timeRange) use ($day) { |
|
528 | return [ |
|
529 | '@type' => 'OpeningHoursSpecification', |
|
530 | 'dayOfWeek' => ucfirst($day), |
|
531 | 'opens' => (string) $timeRange->start(), |
|
532 | 'closes' => (string) $timeRange->end(), |
|
533 | ]; |
|
534 | }); |
|
535 | }); |
|
536 | ||
537 | $exceptions = $this->flatMapExceptions(function (OpeningHoursForDay $openingHoursForDay, string $date) { |
|
538 | if ($openingHoursForDay->isEmpty()) { |
|
@@ 548-556 (lines=9) @@ | ||
545 | ]]; |
|
546 | } |
|
547 | ||
548 | return $openingHoursForDay->map(function (TimeRange $timeRange) use ($date) { |
|
549 | return [ |
|
550 | '@type' => 'OpeningHoursSpecification', |
|
551 | 'opens' => (string) $timeRange->start(), |
|
552 | 'closes' => (string) $timeRange->end(), |
|
553 | 'validFrom' => $date, |
|
554 | 'validThrough' => $date, |
|
555 | ]; |
|
556 | }); |
|
557 | }); |
|
558 | ||
559 | return array_merge($regularHours, $exceptions); |