|
|
@@ -25,44 +25,33 @@ class OpeningSolver |
|
|
|
} |
|
|
|
|
|
|
|
$count = 0; |
|
|
|
$isClosingDay = false; |
|
|
|
|
|
|
|
do { |
|
|
|
if ($count) { |
|
|
|
$date->modify('+1 day'); |
|
|
|
} |
|
|
|
$weekDay = $date->format('N'); |
|
|
|
$isClosingDay = $this->$methodTestDay($weekDay, $openings); |
|
|
|
$testDay = $this->$methodTestDay($weekDay, $openings); |
|
|
|
$count++; |
|
|
|
} while (!$isClosingDay && $count <= 7); |
|
|
|
} while (!$testDay && $count <= 8); |
|
|
|
|
|
|
|
if ($isClosingDay) { |
|
|
|
if ($testDay) { |
|
|
|
return $this->getOpeningByWeekday($weekDay, $openings); |
|
|
|
} |
|
|
|
|
|
|
|
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); |
|
|
|
if ($openingDay && $openingDay->$methodGetTime()) { |
|
|
|
|
|
|
|
if ($openingDay && $openingDay->getTimeEnd()) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
|