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