|
@@ 230-239 (lines=10) @@
|
| 227 |
|
|
| 228 |
|
public function asStructuredData(): array |
| 229 |
|
{ |
| 230 |
|
$regularHours = $this->flatMap(function (OpeningHoursForDay $openingHoursForDay, string $day) { |
| 231 |
|
return $openingHoursForDay->map(function (TimeRange $timeRange) use ($day) { |
| 232 |
|
return [ |
| 233 |
|
'@type' => 'OpeningHoursSpecification', |
| 234 |
|
'dayOfWeek' => ucfirst($day), |
| 235 |
|
'opens' => (string) $timeRange->start(), |
| 236 |
|
'closes' => (string) $timeRange->end(), |
| 237 |
|
]; |
| 238 |
|
}); |
| 239 |
|
}); |
| 240 |
|
|
| 241 |
|
$exceptions = $this->flatMapExceptions(function (OpeningHoursForDay $openingHoursForDay, string $date) { |
| 242 |
|
|
|
@@ 253-261 (lines=9) @@
|
| 250 |
|
]]; |
| 251 |
|
} |
| 252 |
|
|
| 253 |
|
return $openingHoursForDay->map(function (TimeRange $timeRange) use ($date) { |
| 254 |
|
return [ |
| 255 |
|
'@type' => 'OpeningHoursSpecification', |
| 256 |
|
'opens' => $timeRange->start(), |
| 257 |
|
'closes' => $timeRange->end(), |
| 258 |
|
'validFrom' => $date, |
| 259 |
|
'validThrough' => $date, |
| 260 |
|
]; |
| 261 |
|
}); |
| 262 |
|
}); |
| 263 |
|
|
| 264 |
|
return array_merge($regularHours, $exceptions); |