|
@@ 382-391 (lines=10) @@
|
| 379 |
|
|
| 380 |
|
public function asStructuredData(): array |
| 381 |
|
{ |
| 382 |
|
$regularHours = $this->flatMap(function (OpeningHoursForDay $openingHoursForDay, string $day) { |
| 383 |
|
return $openingHoursForDay->map(function (TimeRange $timeRange) use ($day) { |
| 384 |
|
return [ |
| 385 |
|
'@type' => 'OpeningHoursSpecification', |
| 386 |
|
'dayOfWeek' => ucfirst($day), |
| 387 |
|
'opens' => (string) $timeRange->start(), |
| 388 |
|
'closes' => (string) $timeRange->end(), |
| 389 |
|
]; |
| 390 |
|
}); |
| 391 |
|
}); |
| 392 |
|
|
| 393 |
|
$exceptions = $this->flatMapExceptions(function (OpeningHoursForDay $openingHoursForDay, string $date) { |
| 394 |
|
if ($openingHoursForDay->isEmpty()) { |
|
@@ 404-412 (lines=9) @@
|
| 401 |
|
]]; |
| 402 |
|
} |
| 403 |
|
|
| 404 |
|
return $openingHoursForDay->map(function (TimeRange $timeRange) use ($date) { |
| 405 |
|
return [ |
| 406 |
|
'@type' => 'OpeningHoursSpecification', |
| 407 |
|
'opens' => (string) $timeRange->start(), |
| 408 |
|
'closes' => (string) $timeRange->end(), |
| 409 |
|
'validFrom' => $date, |
| 410 |
|
'validThrough' => $date, |
| 411 |
|
]; |
| 412 |
|
}); |
| 413 |
|
}); |
| 414 |
|
|
| 415 |
|
return array_merge($regularHours, $exceptions); |