|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$count = 0; |
|
|
$count = 0; |
|
|
$isClosingDay = false; |
|
|
|
|
|
|
|
|
|
|
|
do { |
|
|
do { |
|
|
if ($count) { |
|
|
if ($count) { |
|
|
$date->modify('+1 day'); |
|
|
$date->modify('+1 day'); |
|
|
} |
|
|
} |
|
|
$weekDay = $date->format('N'); |
|
|
$weekDay = $date->format('N'); |
|
|
$isClosingDay = $this->$methodTestDay($weekDay, $openings); |
|
|
|
|
|
|
|
|
$testDay = $this->$methodTestDay($weekDay, $openings); |
|
|
$count++; |
|
|
$count++; |
|
|
} while (!$isClosingDay && $count <= 7); |
|
|
|
|
|
|
|
|
} while (!$testDay && $count <= 8); |
|
|
|
|
|
|
|
|
if ($isClosingDay) { |
|
|
|
|
|
|
|
|
if ($testDay) { |
|
|
return $this->getOpeningByWeekday($weekDay, $openings); |
|
|
return $this->getOpeningByWeekday($weekDay, $openings); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function isOpeningDay(int $weekDay, array $openings): bool |
|
|
|
|
|
|
|
|
protected function isOpeningDay(int $weekDay, array $openings): bool |
|
|
{ |
|
|
{ |
|
|
return $this->isOpeningOrClosingDay($weekDay, $openings, 'opening'); |
|
|
|
|
|
|
|
|
return (bool) $this->getOpeningByWeekday($weekDay, $openings); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function isClosingDay(int $weekDay, array $openings): bool |
|
|
|
|
|
|
|
|
protected function isClosingDay(int $weekDay, array $openings): bool |
|
|
{ |
|
|
{ |
|
|
return $this->isOpeningOrClosingDay($weekDay, $openings, 'closing'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected function isOpeningOrClosingDay(int $weekDay, array $openings, string $testOpeningOrClosing = 'opening') |
|
|
|
|
|
{ |
|
|
|
|
|
if ($testOpeningOrClosing == 'opening') { |
|
|
|
|
|
$methodGetTime = 'getTimeStart'; |
|
|
|
|
|
} else { |
|
|
|
|
|
$methodGetTime = 'getTimeEnd'; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$openingDay = $this->getOpeningByWeekday($weekDay, $openings); |
|
|
$openingDay = $this->getOpeningByWeekday($weekDay, $openings); |
|
|
if ($openingDay && $openingDay->$methodGetTime()) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($openingDay && $openingDay->getTimeEnd()) { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|