Code cleanup.

This commit is contained in:
James Cole 2016-02-04 07:23:14 +01:00
parent 0df8d096f0
commit bd40615f8e
2 changed files with 34 additions and 33 deletions

View File

@ -31,6 +31,27 @@ class FiscalHelper implements FiscalHelperInterface
}
}
/**
* @param Carbon $date
*
* @return Carbon date object
*/
public function endOfFiscalYear(Carbon $date)
{
// get start of fiscal year for passed date
$endDate = $this->startOfFiscalYear($date);
if ($this->useCustomFiscalYear === true) {
// add 1 year and sub 1 day
$endDate->addYear();
$endDate->subDay();
} else {
$endDate->endOfYear();
}
return $endDate;
}
/**
* @param Carbon $date
*
@ -52,27 +73,7 @@ class FiscalHelper implements FiscalHelperInterface
} else {
$startDate->startOfYear();
}
return $startDate;
}
/**
* @param Carbon $date
*
* @return Carbon date object
*/
public function endOfFiscalYear(Carbon $date)
{
// get start of fiscal year for passed date
$endDate = $this->startOfFiscalYear($date);
if ($this->useCustomFiscalYear === true) {
// add 1 year and sub 1 day
$endDate->addYear();
$endDate->subDay();
} else {
$endDate->endOfYear();
}
return $endDate;
}
}

View File

@ -14,22 +14,22 @@ interface FiscalHelperInterface
/**
* This method produces a clone of the Carbon date object passed, checks preferences
* and calculates the first day of the fiscal year.
* and calculates the last day of the fiscal year.
*
* @param Carbon $date
*
* @return Carbon date object
*/
public function startOfFiscalYear(Carbon $date);
/**
* This method produces a clone of the Carbon date object passed, checks preferences
* and calculates the last day of the fiscal year.
*
* @param Carbon $date
* @param Carbon $date
*
* @return Carbon date object
*/
public function endOfFiscalYear(Carbon $date);
/**
* This method produces a clone of the Carbon date object passed, checks preferences
* and calculates the first day of the fiscal year.
*
* @param Carbon $date
*
* @return Carbon date object
*/
public function startOfFiscalYear(Carbon $date);
}