@@ 267-276 (lines=10) @@ | ||
264 | ||
265 | public function asStructuredData(): array |
|
266 | { |
|
267 | $regularHours = $this->flatMap(function (OpeningHoursForDay $openingHoursForDay, string $day) { |
|
268 | return $openingHoursForDay->map(function (TimeRange $timeRange) use ($day) { |
|
269 | return [ |
|
270 | '@type' => 'OpeningHoursSpecification', |
|
271 | 'dayOfWeek' => ucfirst($day), |
|
272 | 'opens' => (string) $timeRange->start(), |
|
273 | 'closes' => (string) $timeRange->end(), |
|
274 | ]; |
|
275 | }); |
|
276 | }); |
|
277 | ||
278 | $exceptions = $this->flatMapExceptions(function (OpeningHoursForDay $openingHoursForDay, string $date) { |
|
279 | if ($openingHoursForDay->isEmpty()) { |
|
@@ 289-297 (lines=9) @@ | ||
286 | ]]; |
|
287 | } |
|
288 | ||
289 | return $openingHoursForDay->map(function (TimeRange $timeRange) use ($date) { |
|
290 | return [ |
|
291 | '@type' => 'OpeningHoursSpecification', |
|
292 | 'opens' => $timeRange->start(), |
|
293 | 'closes' => $timeRange->end(), |
|
294 | 'validFrom' => $date, |
|
295 | 'validThrough' => $date, |
|
296 | ]; |
|
297 | }); |
|
298 | }); |
|
299 | ||
300 | return array_merge($regularHours, $exceptions); |