mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-03 11:08:28 +00:00
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.
29 lines
962 B
PHP
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;
|
|
}
|
|
}
|