. */ namespace FireflyIII\Support\Calendar\Exceptions; use FireflyIII\Support\Calendar\Periodicity; /** * Class IntervalException */ final class IntervalException extends \Exception { protected $message = 'The periodicity %s is unknown. Choose one of available periodicity: %s'; public readonly Periodicity $periodicity; public readonly array $availableIntervals; /** * @param Periodicity $periodicity * @param array $intervals * @param int $code * @param \Throwable|null $previous * @return IntervalException */ public static function unavailable( Periodicity $periodicity, array $intervals, int $code = 0, ?\Throwable $previous = null ): IntervalException { $message = sprintf( 'The periodicity %s is unknown. Choose one of available periodicity: %s', $periodicity->name, join(', ', $intervals) ); $exception = new IntervalException($message, $code, $previous); $exception->periodicity = $periodicity; $exception->availableIntervals = $intervals; return $exception; } }