mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-19 04:49:30 +00:00
Code cleanup.
This commit is contained in:
@@ -9,6 +9,7 @@ use FireflyIII\Exception\FireflyException;
|
||||
* Class Date
|
||||
*
|
||||
* @package FireflyIII\Shared\Toolkit
|
||||
* @SuppressWarnings("ExcessiveClassComplexity")
|
||||
*/
|
||||
class Date
|
||||
{
|
||||
@@ -16,6 +17,7 @@ class Date
|
||||
* @param Carbon $theDate
|
||||
* @param $repeatFreq
|
||||
* @param $skip
|
||||
* @SuppressWarnings("Cyclomatic")
|
||||
*
|
||||
* @return Carbon
|
||||
* @throws FireflyException
|
||||
@@ -24,6 +26,7 @@ class Date
|
||||
{
|
||||
$date = clone $theDate;
|
||||
$add = ($skip + 1);
|
||||
|
||||
switch ($repeatFreq) {
|
||||
default:
|
||||
throw new FireflyException('Cannot do addPeriod for $repeat_freq ' . $repeatFreq);
|
||||
@@ -60,6 +63,7 @@ class Date
|
||||
/**
|
||||
* @param Carbon $theCurrentEnd
|
||||
* @param $repeatFreq
|
||||
* @SuppressWarnings("Cyclomatic")
|
||||
*
|
||||
* @return mixed
|
||||
* @throws FireflyException
|
||||
@@ -101,11 +105,14 @@ class Date
|
||||
/**
|
||||
* @param Carbon $theCurrentEnd
|
||||
* @param $repeatFreq
|
||||
* @param Carbon $maxDate
|
||||
* @SuppressWarnings("Cyclomatic")
|
||||
* @SuppressWarnings("MethodLength")
|
||||
*
|
||||
* @return mixed
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function endOfX(Carbon $theCurrentEnd, $repeatFreq)
|
||||
public function endOfX(Carbon $theCurrentEnd, $repeatFreq, Carbon $maxDate)
|
||||
{
|
||||
$currentEnd = clone $theCurrentEnd;
|
||||
switch ($repeatFreq) {
|
||||
@@ -139,6 +146,9 @@ class Date
|
||||
$currentEnd->endOfYear();
|
||||
break;
|
||||
}
|
||||
if ($currentEnd > $maxDate) {
|
||||
return clone $maxDate;
|
||||
}
|
||||
|
||||
return $currentEnd;
|
||||
}
|
||||
@@ -146,6 +156,7 @@ class Date
|
||||
/**
|
||||
* @param Carbon $date
|
||||
* @param $repeatFrequency
|
||||
* @SuppressWarnings("Cyclomatic")
|
||||
*
|
||||
* @return string
|
||||
* @throws FireflyException
|
||||
@@ -180,6 +191,7 @@ class Date
|
||||
/**
|
||||
* @param Carbon $theDate
|
||||
* @param $repeatFreq
|
||||
* @SuppressWarnings("Cyclomatic")
|
||||
*
|
||||
* @return Carbon
|
||||
* @throws FireflyException
|
||||
@@ -226,10 +238,10 @@ class Date
|
||||
* @param Carbon $theDate
|
||||
* @param $repeatFreq
|
||||
* @param int $subtract
|
||||
* @SuppressWarnings("Cyclomatic")
|
||||
*
|
||||
* @return Carbon
|
||||
* @throws FireflyException
|
||||
* @internal param Carbon $date
|
||||
*/
|
||||
public function subtractPeriod(Carbon $theDate, $repeatFreq, $subtract = 1)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user