32 lines
948 B
PHP
32 lines
948 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Config;
|
|
|
|
/**
|
|
* How far ahead a booking may be made.
|
|
*
|
|
* Measured from **today**, not from the day being booked: a cap relative to the chosen start date
|
|
* can be pushed out simply by starting later, which is exactly what the previous
|
|
* BookingSeries::MAX_MONTHS rule allowed (a series starting in six months could run to month
|
|
* nine). It governs single bookings and series alike, which is why it lives here rather than on
|
|
* BookingSeries.
|
|
*
|
|
* ROLE_ADMIN is exempt -- see BookingRequest::$unlimitedHorizon.
|
|
*/
|
|
final class BookingHorizon
|
|
{
|
|
public const MONTHS = 3;
|
|
|
|
/**
|
|
* The last day that may still be booked. Inclusive.
|
|
*/
|
|
public static function latest(?\DateTimeImmutable $today = null): \DateTimeImmutable
|
|
{
|
|
return ($today ?? new \DateTimeImmutable('today'))
|
|
->setTime(0, 0)
|
|
->modify(\sprintf('+%d months', self::MONTHS));
|
|
}
|
|
}
|