Files
firefly-iii/app/Support/Calendar/Exceptions/IntervalException.php
Antonio Spinelli dbb7ed3d5d Add the Calendar Calculator
It encapsulates some date operations like sum. The result will be the
calculated date when calling the nextDateByInterval method, given the
date, periodicity, and skipInterval parameters.

For example, given a date of 2019-12-31, monthly periodicity, and skip
interval 0, the results will be 2020-01-31. Also, if the skip interval
is 1, the result is 2020-02-29. This is because the next date will add
another month to the current range.
2023-07-03 13:46:29 -03:00

29 lines
962 B
PHP

<?php
namespace FireflyIII\Support\Calendar\Exceptions;
use FireflyIII\Support\Calendar\Periodicity;
use JetBrains\PhpStorm\Pure;
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;
public static function unavailable(Periodicity $periodicity, array $instervals, int $code = 0, ?\Throwable $previous = null): IntervalException
{
$message = sprintf(
'The periodicity %s is unknown. Choose one of available periodicity: %s',
$periodicity->name,
join(', ', $instervals)
);
$exception = new IntervalException($message, $code, $previous);
$exception->periodicity = $periodicity;
$exception->availableIntervals = $instervals;
return $exception;
}
}