magento2-module-store-locator
magento2-module-store-locator copied to clipboard
Fix @return value ?RetailerTimeSlotInterface and not array
https://github.com/Smile-SA/magento2-module-store-locator/blob/14655c0bd95ba360716205505efc8e94d743b4d8/Model/Retailer/ScheduleManagement.php#L57
If a TimeSloteInterface is found, return that interface and not an array.
Change
/**
* Retrieve opening hours for a given date
*
* @SuppressWarnings(PHPMD.StaticAccess)
*
* @param RetailerInterface $retailer The retailer
* @param null $dateTime The date to retrieve opening hours for
*
* @return RetailerTimeSlotInterface|null
*/
public function getOpeningHours($retailer, $dateTime = null): ?RetailerTimeSlotInterface
{
$dayOpening = null;
if ($dateTime == null) {
$dateTime = new \DateTime();
}
if (is_string($dateTime)) {
$dateTime = \DateTime::createFromFormat('Y-m-d', $dateTime);
}
$dayOfWeek = $dateTime->format('w');
$date = $dateTime->format('Y-m-d');
$openingHours = $retailer->getExtensionAttributes()->getOpeningHours();
$specialOpeningHours = $retailer->getExtensionAttributes()->getSpecialOpeningHours();
if (isset($openingHours[$dayOfWeek])) {
$dayOpening = $openingHours[$dayOfWeek];
}
if (isset($specialOpeningHours[$date])) {
$dayOpening = $specialOpeningHours[$date];
}
return $dayOpening;
}