$this->cancel_hours, 'reschedule_hours' => $this->reschedule_hours, 'max_reschedules' => $this->max_reschedules, ); } /** * Whether the customer can still cancel. * * @param int $start Booking start. * @param int $now Now. */ public function can_cancel( int $start, int $now ): bool { return $this->cancel_hours >= 0 && $start - $now >= $this->cancel_hours * 3600; } /** * Whether the customer can still move the booking. * * @param int $start Booking start. * @param int $now Now. * @param int $rescheduled Times already moved. */ public function can_reschedule( int $start, int $now, int $rescheduled ): bool { return $this->reschedule_hours >= 0 && $start - $now >= $this->reschedule_hours * 3600 && $rescheduled < $this->max_reschedules; } /** * Read hours of notice, -1 for off. * * @param mixed $value Raw. */ private static function hours( mixed $value ): int { $hours = is_numeric( $value ) ? (int) $value : 24; return $hours < 0 ? -1 : min( $hours, CancellationPolicy::MAX_HOURS ); } }