本文整理汇总了PHP中Reservation::getEndDate方法的典型用法代码示例。如果您正苦于以下问题:PHP Reservation::getEndDate方法的具体用法?PHP Reservation::getEndDate怎么用?PHP Reservation::getEndDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reservation
的用法示例。
在下文中一共展示了Reservation::getEndDate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkForValidReservation
public function checkForValidReservation(Reservation $reservation)
{
foreach ($this->reservations as $existingReservation) {
if ($reservation->getStartDate() >= $existingReservation->getStartDate() && $reservation->getStartDate() <= $existingReservation->getEndDate()) {
throw new EReservationException($this->roomNumber, $reservation);
} elseif ($reservation->getEndDate() >= $existingReservation->getStartDate() && $reservation->getEndDate() <= $existingReservation->getEndDate()) {
throw new EReservationException($this->roomNumber, $reservation);
}
}
}
示例2: addReservation
public function addReservation(Reservation $reservation)
{
if (!$this->roomIsFree($reservation->getStartDate(), $reservation->getEndDate())) {
throw new EReservationException();
}
$this->reservations[] = $reservation;
}
示例3:
function __construct($roomNumber, Reservation $reservation)
{
$this->message = "Room " . $roomNumber . " is already occupied for period from " . $reservation->getStartDate()->format("d-m-y") . " to " . $reservation->getEndDate()->format("d-m-y") . PHP_EOL;
}
示例4: isCollidingReservationExists
private function isCollidingReservationExists(Reservation $reservation)
{
$reservationStartDate = $reservation->getStartDate();
$reservationEndDate = $reservation->getEndDate();
for ($i = 0; $i < count($this->reservations); $i++) {
if ($reservationStartDate > $this->reservations[$i]->getEndDate() || $reservationEndDate < $this->reservations[$i]->getStartDate()) {
return true;
}
return false;
}
}
示例5: addReservation
public function addReservation(Reservation $reservation)
{
if (!empty($this->reservations)) {
foreach ($this->reservations as $res) {
if ($reservation->getStartDate() >= $res->getStartDate() && $reservation->getStartDate() <= $res->getEndDate()) {
throw new EReservationException("A reservation already exists in that period.");
}
if ($reservation->getEndDate() >= $res->getStartDate() && $reservation->getEndDate() <= $res->getEndDate()) {
throw new EReservationException("A reservation already exists in that period.");
}
}
}
$this->reservations[] = $reservation;
}
示例6: compareTwoReservationsForOverlapping
private function compareTwoReservationsForOverlapping(Reservation $newReservation, Reservation $existingReservation)
{
if ($newReservation->getStartDate() >= $existingReservation->getStartDate() && $newReservation->getStartDate() <= $existingReservation->getEndDate() || $newReservation->getEndDate() <= $existingReservation->getEndDate() && $newReservation->getEndDate() >= $existingReservation->getStartDate() || $newReservation->getStartDate() <= $existingReservation->getStartDate() && $newReservation->getEndDate() >= $existingReservation->getEndDate()) {
throw new EReservationException();
}
}
示例7: areOverlappingReservations
private function areOverlappingReservations(Reservation $reservation1, Reservation $reservation2)
{
$secondStartsDuringFirst = $reservation2->getStarDate() >= $reservation1->getStarDate() && $reservation2->getStarDate() <= $reservation1->getEndDate();
$firstStartsDuringSecond = $reservation1->getStarDate() >= $reservation2->getStarDate() && $reservation1->getStarDate() <= $reservation2->getEndDate();
return $firstStartsDuringSecond || $secondStartsDuringFirst;
}