Skip to content

Commit

Permalink
feat: refactor typo'd method name
Browse files Browse the repository at this point in the history
  • Loading branch information
owenvoke committed Sep 5, 2024
1 parent 969e6ff commit 8acb327
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
10 changes: 9 additions & 1 deletion src/Calendars/YasumiUkCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
18 changes: 12 additions & 6 deletions src/Contracts/UkCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion src/UkTaxAllowanceCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Calendars/YasumiUkCalendarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down

0 comments on commit 8acb327

Please sign in to comment.