Code cleanup.

This commit is contained in:
James Cole
2014-12-14 20:40:02 +01:00
parent 8e6ca0dd05
commit 900dea2c66
36 changed files with 384 additions and 1094 deletions

View File

@@ -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)
{