Code cleanup.

This commit is contained in:
James Cole
2023-12-20 19:35:52 +01:00
parent c4f6366642
commit 64ec0cf62e
997 changed files with 12908 additions and 28136 deletions

View File

@@ -1,6 +1,5 @@
<?php
/*
* IntervalException.php
* Copyright (c) 2023 james@firefly-iii.org
@@ -25,42 +24,32 @@ declare(strict_types=1);
namespace FireflyIII\Exceptions;
use Exception;
use FireflyIII\Support\Calendar\Periodicity;
use Throwable;
/**
* Class IntervalException
*/
final class IntervalException extends Exception
final class IntervalException extends \Exception
{
public array $availableIntervals;
public Periodicity $periodicity;
/** @var mixed */
protected $message = 'The periodicity %s is unknown. Choose one of available periodicity: %s';
public function __construct(string $message = '', int $code = 0, ?Throwable $previous = null)
public function __construct(string $message = '', int $code = 0, ?\Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
$this->availableIntervals = [];
$this->periodicity = Periodicity::Monthly;
}
/**
* @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
): self
{
?\Throwable $previous = null
): self {
$message = sprintf(
'The periodicity %s is unknown. Choose one of available periodicity: %s',
$periodicity->name,
@@ -70,6 +59,7 @@ final class IntervalException extends Exception
$exception = new self($message, $code, $previous);
$exception->periodicity = $periodicity;
$exception->availableIntervals = $intervals;
return $exception;
}
}