|
@@ 294-303 (lines=10) @@
|
| 291 |
|
|
| 292 |
|
public function asStructuredData(): array |
| 293 |
|
{ |
| 294 |
|
$regularHours = $this->flatMap(function (OpeningHoursForDay $openingHoursForDay, string $day) { |
| 295 |
|
return $openingHoursForDay->map(function (TimeRange $timeRange) use ($day) { |
| 296 |
|
return [ |
| 297 |
|
'@type' => 'OpeningHoursSpecification', |
| 298 |
|
'dayOfWeek' => ucfirst($day), |
| 299 |
|
'opens' => (string) $timeRange->start(), |
| 300 |
|
'closes' => (string) $timeRange->end(), |
| 301 |
|
]; |
| 302 |
|
}); |
| 303 |
|
}); |
| 304 |
|
|
| 305 |
|
$exceptions = $this->flatMapExceptions(function (OpeningHoursForDay $openingHoursForDay, string $date) { |
| 306 |
|
if ($openingHoursForDay->isEmpty()) { |
|
@@ 316-324 (lines=9) @@
|
| 313 |
|
]]; |
| 314 |
|
} |
| 315 |
|
|
| 316 |
|
return $openingHoursForDay->map(function (TimeRange $timeRange) use ($date) { |
| 317 |
|
return [ |
| 318 |
|
'@type' => 'OpeningHoursSpecification', |
| 319 |
|
'opens' => $timeRange->start(), |
| 320 |
|
'closes' => $timeRange->end(), |
| 321 |
|
'validFrom' => $date, |
| 322 |
|
'validThrough' => $date, |
| 323 |
|
]; |
| 324 |
|
}); |
| 325 |
|
}); |
| 326 |
|
|
| 327 |
|
return array_merge($regularHours, $exceptions); |