From 8acb3275a2a373a734b8c8984362f05520684973 Mon Sep 17 00:00:00 2001 From: Owen Voke Date: Thu, 5 Sep 2024 13:21:06 +0100 Subject: [PATCH] feat: refactor typo'd method name --- src/Calendars/YasumiUkCalendar.php | 10 +++++++++- src/Contracts/UkCalendar.php | 18 ++++++++++++------ src/UkTaxAllowanceCalculator.php | 2 +- tests/Calendars/YasumiUkCalendarTest.php | 2 +- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/Calendars/YasumiUkCalendar.php b/src/Calendars/YasumiUkCalendar.php index d30e24d..eb9d887 100644 --- a/src/Calendars/YasumiUkCalendar.php +++ b/src/Calendars/YasumiUkCalendar.php @@ -33,16 +33,24 @@ public function isWorkingDay(Carbon $date): bool && ! $ukCalendar->isHoliday($date); } - public function closestFuturWorkingDay(Carbon $date): Carbon + /** {@inheritdoc} */ + public function closestFutureWorkingDay(Carbon $date): Carbon { return $this->closestWorkingDay($date, self::FUTURE); } + /** {@inheritdoc} */ public function closestPastWorkingDay(Carbon $date): Carbon { return $this->closestWorkingDay($date, self::PAST); } + /** {@inheritdoc} */ + public function closestFuturWorkingDay(Carbon $date): Carbon + { + return $this->closestFutureWorkingDay($date); + } + protected function closestWorkingDay(Carbon $date, int $direction): Carbon { $workingDay = $date->copy(); diff --git a/src/Contracts/UkCalendar.php b/src/Contracts/UkCalendar.php index cb6e6aa..841ce10 100644 --- a/src/Contracts/UkCalendar.php +++ b/src/Contracts/UkCalendar.php @@ -7,27 +7,33 @@ interface UkCalendar { /** - * Indicates if a Carbon $date is a weekend day or not + * Indicates if the provided date is a weekend day or not. */ public function isWeekendDay(Carbon $date): bool; /** - * Indicates if a Carbon $date is a uk holiday or not + * Indicates if the provided date is a UK holiday or not. */ public function isHoliday(Carbon $date): bool; /** - * Indicates if a Carbon $date is a working day (not a holiday nor a weekend day) + * Indicates if the provided date is a working day (not a holiday nor a weekend day). */ public function isWorkingDay(Carbon $date): bool; /** - * Returns the closest working day in the future in comparaison to the passed Carbon $date + * Returns the closest working day in the future in comparison to the provided date. */ - public function closestFuturWorkingDay(Carbon $date): Carbon; + public function closestFutureWorkingDay(Carbon $date): Carbon; /** - * Returns the closest working day in the past in comparaison to the passed Carbon $date + * Returns the closest working day in the past in comparison to the provided date. */ public function closestPastWorkingDay(Carbon $date): Carbon; + + /** + * @deprecated Use closestFutureWorkingDay() instead. + * @see closestFutureWorkingDay() + */ + public function closestFuturWorkingDay(Carbon $date): Carbon; } diff --git a/src/UkTaxAllowanceCalculator.php b/src/UkTaxAllowanceCalculator.php index 36058cd..52794f5 100644 --- a/src/UkTaxAllowanceCalculator.php +++ b/src/UkTaxAllowanceCalculator.php @@ -47,7 +47,7 @@ public function weeklyEndDatesBetween(Carbon $start, Carbon $end): Collection */ public function monthlyEndDatesBetween(Carbon $start, Carbon $end): Collection { - $dateStart = $this->calendar->closestFuturWorkingDay($start); + $dateStart = $this->calendar->closestFutureWorkingDay($start); $dateEnd = $this->calendar->closestPastWorkingDay($end); if ($dateStart->isSameMonth($dateEnd)) { diff --git a/tests/Calendars/YasumiUkCalendarTest.php b/tests/Calendars/YasumiUkCalendarTest.php index a174031..afbf13a 100644 --- a/tests/Calendars/YasumiUkCalendarTest.php +++ b/tests/Calendars/YasumiUkCalendarTest.php @@ -21,7 +21,7 @@ it('returns correct closest future working day', function ($day, $expectedClosestFutureWorkingDay) { $day = Carbon::createFromFormat('Y-m-d', $day); - $closestFutureWorkingDay = $this->calendar->closestFuturWorkingDay($day); + $closestFutureWorkingDay = $this->calendar->closestFutureWorkingDay($day); expect($closestFutureWorkingDay->toDateString())->toEqual($expectedClosestFutureWorkingDay); })->with([