本文整理匯總了PHP中Reservation::getStartDate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Reservation::getStartDate方法的具體用法?PHP Reservation::getStartDate怎麽用?PHP Reservation::getStartDate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Reservation
的用法示例。
在下文中一共展示了Reservation::getStartDate方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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();
}
}