From 9d5fcdfc736d1982d9d890f08d0c2417652e380d Mon Sep 17 00:00:00 2001 From: Niels Vanpachtenbeke <10651054+Nielsvanpach@users.noreply.github.com> Date: Thu, 8 Feb 2024 12:32:34 +0100 Subject: [PATCH] cleanup --- src/Countries/Spain.php | 4 ++-- src/Countries/UnitedStates.php | 27 +++++++++------------------ 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/Countries/Spain.php b/src/Countries/Spain.php index 27a7f166f..46a46e805 100644 --- a/src/Countries/Spain.php +++ b/src/Countries/Spain.php @@ -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 */ diff --git a/src/Countries/UnitedStates.php b/src/Countries/UnitedStates.php index 695103dca..9cccfad73 100644 --- a/src/Countries/UnitedStates.php +++ b/src/Countries/UnitedStates.php @@ -2,8 +2,6 @@ namespace Spatie\Holidays\Countries; -use Carbon\CarbonImmutable; - class UnitedStates extends Country { public function countryCode(): string @@ -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'; @@ -27,23 +25,16 @@ protected function allHolidays(int $year): array return $holidays; } - /** @return array */ - protected function variableHolidays(int $year): array + /** @return array */ + 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', ]; } }