Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Nielsvanpach committed Feb 8, 2024
1 parent bf1c6a5 commit 9d5fcdf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/Countries/Spain.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ protected function regionHolidays(int $year): array
$method = "regionHolidays{$year}";
if (method_exists($this, $method)) {
return $this->$method();
} else {
throw InvalidYear::range($this->countryCode()." ({$this->region})", 2022, 2024);
}

throw InvalidYear::range($this->countryCode()." ({$this->region})", 2022, 2024);
}

/** @return array<string, string> */
Expand Down
27 changes: 9 additions & 18 deletions src/Countries/UnitedStates.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;

class UnitedStates extends Country
{
public function countryCode(): string
Expand All @@ -18,7 +16,7 @@ protected function allHolidays(int $year): array
'Independence Day' => '07-04',
'Veterans Day' => '11-11',
'Christmas' => '12-25',
], $this->variableHolidays($year));
], $this->variableHolidays());

if ($year >= 2021) {
$holidays['Juneteenth National Independence Day'] = '06-19';
Expand All @@ -27,23 +25,16 @@ protected function allHolidays(int $year): array
return $holidays;
}

/** @return array<string, CarbonImmutable> */
protected function variableHolidays(int $year): array
/** @return array<string, string> */
protected function variableHolidays(): array
{
$martinLutherKingDay = new CarbonImmutable("third monday of January $year", 'America/Los_Angeles');
$presidentsDay = new CarbonImmutable("third monday of February $year", 'America/Los_Angeles');
$memorialDay = new CarbonImmutable("last monday of May $year", 'America/Los_Angeles');
$laborDay = new CarbonImmutable("first monday of September $year", 'America/Los_Angeles');
$columbusDay = new CarbonImmutable("second monday of October $year", 'America/Los_Angeles');
$thanksgiving = new CarbonImmutable("fourth thursday of November $year", 'America/Los_Angeles');

return [
'Martin Luther King Day' => $martinLutherKingDay,
'Presidents\' Day' => $presidentsDay,
'Memorial Day' => $memorialDay,
'Labor Day' => $laborDay,
'Columbus Day' => $columbusDay,
'Thanksgiving' => $thanksgiving,
'Martin Luther King Day' => 'third monday of January',
'Presidents\' Day' => 'third monday of February',
'Memorial Day' => 'last monday of May',
'Labor Day' => 'first monday of September',
'Columbus Day' => 'second monday of October',
'Thanksgiving' => 'fourth thursday of November',
];
}
}

0 comments on commit 9d5fcdf

Please sign in to comment.