From bd40615f8e27666737ebce9bec0d5ce808335277 Mon Sep 17 00:00:00 2001 From: James Cole Date: Thu, 4 Feb 2016 07:23:14 +0100 Subject: [PATCH] Code cleanup. --- app/Helpers/FiscalHelper.php | 43 ++++++++++++++------------- app/Helpers/FiscalHelperInterface.php | 24 +++++++-------- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/app/Helpers/FiscalHelper.php b/app/Helpers/FiscalHelper.php index 1d33aa5d8f..5b15450be8 100644 --- a/app/Helpers/FiscalHelper.php +++ b/app/Helpers/FiscalHelper.php @@ -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; - } } diff --git a/app/Helpers/FiscalHelperInterface.php b/app/Helpers/FiscalHelperInterface.php index f4ec6fba1a..e5f805a855 100644 --- a/app/Helpers/FiscalHelperInterface.php +++ b/app/Helpers/FiscalHelperInterface.php @@ -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); + }