|
@@ 420-429 (lines=10) @@
|
| 417 |
|
|
| 418 |
|
public function asStructuredData(): array |
| 419 |
|
{ |
| 420 |
|
$regularHours = $this->flatMap(function (OpeningHoursForDay $openingHoursForDay, string $day) { |
| 421 |
|
return $openingHoursForDay->map(function (TimeRange $timeRange) use ($day) { |
| 422 |
|
return [ |
| 423 |
|
'@type' => 'OpeningHoursSpecification', |
| 424 |
|
'dayOfWeek' => ucfirst($day), |
| 425 |
|
'opens' => (string) $timeRange->start(), |
| 426 |
|
'closes' => (string) $timeRange->end(), |
| 427 |
|
]; |
| 428 |
|
}); |
| 429 |
|
}); |
| 430 |
|
|
| 431 |
|
$exceptions = $this->flatMapExceptions(function (OpeningHoursForDay $openingHoursForDay, string $date) { |
| 432 |
|
if ($openingHoursForDay->isEmpty()) { |
|
@@ 442-450 (lines=9) @@
|
| 439 |
|
]]; |
| 440 |
|
} |
| 441 |
|
|
| 442 |
|
return $openingHoursForDay->map(function (TimeRange $timeRange) use ($date) { |
| 443 |
|
return [ |
| 444 |
|
'@type' => 'OpeningHoursSpecification', |
| 445 |
|
'opens' => (string) $timeRange->start(), |
| 446 |
|
'closes' => (string) $timeRange->end(), |
| 447 |
|
'validFrom' => $date, |
| 448 |
|
'validThrough' => $date, |
| 449 |
|
]; |
| 450 |
|
}); |
| 451 |
|
}); |
| 452 |
|
|
| 453 |
|
return array_merge($regularHours, $exceptions); |