|
@@ 388-397 (lines=10) @@
|
| 385 |
|
|
| 386 |
|
public function asStructuredData(): array |
| 387 |
|
{ |
| 388 |
|
$regularHours = $this->flatMap(function (OpeningHoursForDay $openingHoursForDay, string $day) { |
| 389 |
|
return $openingHoursForDay->map(function (TimeRange $timeRange) use ($day) { |
| 390 |
|
return [ |
| 391 |
|
'@type' => 'OpeningHoursSpecification', |
| 392 |
|
'dayOfWeek' => ucfirst($day), |
| 393 |
|
'opens' => (string) $timeRange->start(), |
| 394 |
|
'closes' => (string) $timeRange->end(), |
| 395 |
|
]; |
| 396 |
|
}); |
| 397 |
|
}); |
| 398 |
|
|
| 399 |
|
$exceptions = $this->flatMapExceptions(function (OpeningHoursForDay $openingHoursForDay, string $date) { |
| 400 |
|
if ($openingHoursForDay->isEmpty()) { |
|
@@ 410-418 (lines=9) @@
|
| 407 |
|
]]; |
| 408 |
|
} |
| 409 |
|
|
| 410 |
|
return $openingHoursForDay->map(function (TimeRange $timeRange) use ($date) { |
| 411 |
|
return [ |
| 412 |
|
'@type' => 'OpeningHoursSpecification', |
| 413 |
|
'opens' => (string) $timeRange->start(), |
| 414 |
|
'closes' => (string) $timeRange->end(), |
| 415 |
|
'validFrom' => $date, |
| 416 |
|
'validThrough' => $date, |
| 417 |
|
]; |
| 418 |
|
}); |
| 419 |
|
}); |
| 420 |
|
|
| 421 |
|
return array_merge($regularHours, $exceptions); |