From 7fcb1769e68394178ab2121929a6f3d16e34c0cc Mon Sep 17 00:00:00 2001 From: Victor Ikpeba Date: Thu, 18 Jan 2024 13:11:51 +0000 Subject: [PATCH 01/11] Added holidays for `Ghana` --- src/Countries/Ghana.php | 48 +++++++++++++++++++ .../it_can_calculate_ghana_holidays.snap | 46 ++++++++++++++++++ tests/Countries/GhanaTest.php | 18 +++++++ 3 files changed, 112 insertions(+) create mode 100644 src/Countries/Ghana.php create mode 100644 tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_ghana_holidays.snap create mode 100644 tests/Countries/GhanaTest.php diff --git a/src/Countries/Ghana.php b/src/Countries/Ghana.php new file mode 100644 index 000000000..c75ccb5b0 --- /dev/null +++ b/src/Countries/Ghana.php @@ -0,0 +1,48 @@ + '01-01', + 'Constitution Day' => '01-07', + 'Independence Day' => '03-06', + 'May Day' => '05-01', + 'Founders Day' => '08-04', + 'Kwame Nkrumah Memorial Day' => '09-21', + 'Christmas Day' => '12-25', + 'Boxing Day' => '12-26', + ], $this->variableHolidays($year)); + } + + /** @return array */ + protected function variableHolidays(int $year): array + { + $easter = CarbonImmutable::createFromTimestamp(easter_date($year)) + ->setTimezone('Africa/Accra'); + + $farmersDay = (new CarbonImmutable('first friday of December ' . $year))->setTimezone('Africa/Accra'); + + return [ + 'Farmers Day' => $farmersDay->addDay(), + + 'Good Friday' => $easter->subDay(2), + 'Easter Monday' => $easter->addDay(), + + // NB: *** There are no fixed dates for the Eid-Ul-Fitr and Eid-Ul-Adha because they are movable feasts. + // The dates for their observation are provided by the Office of the Chief Imam in the course of the year. + // 'Eid-Ul-Fitr' => "", + // 'Eid-Ul-Adha' => "", + ]; + } +} diff --git a/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_ghana_holidays.snap b/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_ghana_holidays.snap new file mode 100644 index 000000000..bd02a7d77 --- /dev/null +++ b/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_ghana_holidays.snap @@ -0,0 +1,46 @@ +[ + { + "name": "New Year Day", + "date": "2024-01-01" + }, + { + "name": "Constitution Day", + "date": "2024-01-07" + }, + { + "name": "Independence Day", + "date": "2024-03-06" + }, + { + "name": "Good Friday", + "date": "2024-03-29" + }, + { + "name": "Easter Monday", + "date": "2024-04-01" + }, + { + "name": "May Day", + "date": "2024-05-01" + }, + { + "name": "Founders Day", + "date": "2024-08-04" + }, + { + "name": "Kwame Nkrumah Memorial Day", + "date": "2024-09-21" + }, + { + "name": "Farmers Day", + "date": "2024-12-06" + }, + { + "name": "Christmas Day", + "date": "2024-12-25" + }, + { + "name": "Boxing Day", + "date": "2024-12-26" + } +] \ No newline at end of file diff --git a/tests/Countries/GhanaTest.php b/tests/Countries/GhanaTest.php new file mode 100644 index 000000000..16f29c491 --- /dev/null +++ b/tests/Countries/GhanaTest.php @@ -0,0 +1,18 @@ +get(); + + expect($holidays) + ->toBeArray() + ->not()->toBeEmpty(); + + expect(formatDates($holidays))->toMatchSnapshot(); +}); From 1d7836e997c1a48f47a5fa8913a88ab444742796 Mon Sep 17 00:00:00 2001 From: Victor Ikpeba Date: Thu, 18 Jan 2024 15:04:39 +0000 Subject: [PATCH 02/11] fix timezone when creating farmers day --- src/Countries/Ghana.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Countries/Ghana.php b/src/Countries/Ghana.php index c75ccb5b0..ec886591b 100644 --- a/src/Countries/Ghana.php +++ b/src/Countries/Ghana.php @@ -31,12 +31,12 @@ protected function variableHolidays(int $year): array $easter = CarbonImmutable::createFromTimestamp(easter_date($year)) ->setTimezone('Africa/Accra'); - $farmersDay = (new CarbonImmutable('first friday of December ' . $year))->setTimezone('Africa/Accra'); + $farmersDay = (new CarbonImmutable('first friday of December ' . $year, 'Africa/Accra')); return [ - 'Farmers Day' => $farmersDay->addDay(), + 'Farmers Day' => $farmersDay, - 'Good Friday' => $easter->subDay(2), + 'Good Friday' => $easter->subDays(2), 'Easter Monday' => $easter->addDay(), // NB: *** There are no fixed dates for the Eid-Ul-Fitr and Eid-Ul-Adha because they are movable feasts. From a9f91893cd3068579fbca40b06c2c327942bc155 Mon Sep 17 00:00:00 2001 From: Victor Ikpeba Date: Sat, 20 Jan 2024 13:50:50 +0000 Subject: [PATCH 03/11] Updated holidays that falls within weekend to be observed on the next monday --- src/Countries/Ghana.php | 86 ++++++++++++++++--- .../it_can_calculate_ghana_holidays.snap | 12 +-- 2 files changed, 79 insertions(+), 19 deletions(-) diff --git a/src/Countries/Ghana.php b/src/Countries/Ghana.php index ec886591b..5cfb04ecc 100644 --- a/src/Countries/Ghana.php +++ b/src/Countries/Ghana.php @@ -6,36 +6,96 @@ class Ghana extends Country { + + protected $timezone = 'Africa/Accra'; + public function countryCode(): string { return 'gh'; } + protected function christmasDay(int $year): array + { + $christmasDay = new CarbonImmutable($year . "-12-25", $this->timezone); + $key = 'Christmas Day'; + + if ($christmasDay->isSaturday()) { + $key .= ' (substitute day)'; + $christmasDay = $christmasDay->next('monday'); + } + + if ($christmasDay->isSunday()) { + $key .= ' (substitute day)'; + $christmasDay = $christmasDay->next('tuesday'); + } + + return [$key => $christmasDay]; + } + + + protected function boxingDay(int $year): array + { + $christmasDay = new CarbonImmutable($year . "-12-25", $this->timezone); + $boxingDay = new CarbonImmutable($year . "-12-26", $this->timezone); + $key = 'Boxing Day'; + + if ($christmasDay->isFriday()) { + $key .= ' (substitute day)'; + $boxingDay = $boxingDay->next('monday'); + } + + if ($christmasDay->isSaturday()) { + $key .= ' (substitute day)'; + $boxingDay = $boxingDay->next('tuesday'); + } + + return [$key => $boxingDay]; + } + + /** + * Get holiday + * + * If it falls on a weekend, the new day to be observed is the next monday + * + */ + protected function getHoliday(string $nameOfHoliday, int $year, string $monthAndDay): array + { + $newYearsDay = new CarbonImmutable($year . "-" . $monthAndDay, $this->timezone); + $key = $nameOfHoliday; + + if ($newYearsDay->isWeekend()) { + $key .= ' (substitute day)'; + $newYearsDay = $newYearsDay->next('monday'); + } + + return [$key => $newYearsDay]; + } + protected function allHolidays(int $year): array { - return array_merge([ - 'New Year Day' => '01-01', - 'Constitution Day' => '01-07', - 'Independence Day' => '03-06', - 'May Day' => '05-01', - 'Founders Day' => '08-04', - 'Kwame Nkrumah Memorial Day' => '09-21', - 'Christmas Day' => '12-25', - 'Boxing Day' => '12-26', - ], $this->variableHolidays($year)); + return array_merge( + $this->getHoliday('New Year Day', $year, "01-01"), + $this->getHoliday('Constitution Day', $year, "01-07"), + $this->getHoliday('Independence Day', $year, "03-06"), + $this->getHoliday('May Day', $year, "05-01"), + $this->getHoliday('Founders Day', $year, "08-04"), + $this->getHoliday('Kwame Nkrumah Memorial Day', $year, "09-21"), + $this->christmasDay($year), + $this->boxingDay($year), + $this->variableHolidays($year) + ); } /** @return array */ protected function variableHolidays(int $year): array { $easter = CarbonImmutable::createFromTimestamp(easter_date($year)) - ->setTimezone('Africa/Accra'); + ->setTimezone($this->timezone); - $farmersDay = (new CarbonImmutable('first friday of December ' . $year, 'Africa/Accra')); + $farmersDay = (new CarbonImmutable('first friday of December ' . $year, $this->timezone)); return [ 'Farmers Day' => $farmersDay, - 'Good Friday' => $easter->subDays(2), 'Easter Monday' => $easter->addDay(), diff --git a/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_ghana_holidays.snap b/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_ghana_holidays.snap index bd02a7d77..3109f1842 100644 --- a/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_ghana_holidays.snap +++ b/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_ghana_holidays.snap @@ -4,8 +4,8 @@ "date": "2024-01-01" }, { - "name": "Constitution Day", - "date": "2024-01-07" + "name": "Constitution Day (substitute day)", + "date": "2024-01-08" }, { "name": "Independence Day", @@ -24,12 +24,12 @@ "date": "2024-05-01" }, { - "name": "Founders Day", - "date": "2024-08-04" + "name": "Founders Day (substitute day)", + "date": "2024-08-05" }, { - "name": "Kwame Nkrumah Memorial Day", - "date": "2024-09-21" + "name": "Kwame Nkrumah Memorial Day (substitute day)", + "date": "2024-09-23" }, { "name": "Farmers Day", From b57f4edd6a5a648ffda2c2cfd0b54b8da46c9dfc Mon Sep 17 00:00:00 2001 From: Victor Ikpeba Date: Wed, 24 Jan 2024 16:24:41 +0000 Subject: [PATCH 04/11] Fix return types --- src/Countries/Ghana.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Countries/Ghana.php b/src/Countries/Ghana.php index 5cfb04ecc..a8674a4fe 100644 --- a/src/Countries/Ghana.php +++ b/src/Countries/Ghana.php @@ -7,13 +7,16 @@ class Ghana extends Country { - protected $timezone = 'Africa/Accra'; + protected string $timezone = 'Africa/Accra'; public function countryCode(): string { return 'gh'; } + /** + * @return array + */ protected function christmasDay(int $year): array { $christmasDay = new CarbonImmutable($year . "-12-25", $this->timezone); @@ -32,7 +35,9 @@ protected function christmasDay(int $year): array return [$key => $christmasDay]; } - + /** + * @return array + */ protected function boxingDay(int $year): array { $christmasDay = new CarbonImmutable($year . "-12-25", $this->timezone); @@ -56,6 +61,8 @@ protected function boxingDay(int $year): array * Get holiday * * If it falls on a weekend, the new day to be observed is the next monday + * + * @return array * */ protected function getHoliday(string $nameOfHoliday, int $year, string $monthAndDay): array From 16e18090f9c0fa5115dadfa3f62394938881c692 Mon Sep 17 00:00:00 2001 From: Victor Ikpeba Date: Wed, 31 Jan 2024 12:07:14 +0000 Subject: [PATCH 05/11] pr suggestions implemented --- src/Countries/Ghana.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Countries/Ghana.php b/src/Countries/Ghana.php index a8674a4fe..a272623d6 100644 --- a/src/Countries/Ghana.php +++ b/src/Countries/Ghana.php @@ -14,12 +14,21 @@ public function countryCode(): string return 'gh'; } + /** + * Return carbon date for christmas + * @return CarbonImmutable + */ + protected function getChristmasDay(int $year) + { + return new CarbonImmutable($year . "-12-25"); + } + /** * @return array */ protected function christmasDay(int $year): array { - $christmasDay = new CarbonImmutable($year . "-12-25", $this->timezone); + $christmasDay = $this->getChristmasDay($year); $key = 'Christmas Day'; if ($christmasDay->isSaturday()) { @@ -40,7 +49,7 @@ protected function christmasDay(int $year): array */ protected function boxingDay(int $year): array { - $christmasDay = new CarbonImmutable($year . "-12-25", $this->timezone); + $christmasDay = $this->getChristmasDay($year); $boxingDay = new CarbonImmutable($year . "-12-26", $this->timezone); $key = 'Boxing Day'; @@ -96,8 +105,7 @@ protected function allHolidays(int $year): array /** @return array */ protected function variableHolidays(int $year): array { - $easter = CarbonImmutable::createFromTimestamp(easter_date($year)) - ->setTimezone($this->timezone); + $easter = $this->easter($year); $farmersDay = (new CarbonImmutable('first friday of December ' . $year, $this->timezone)); From 788a241c6fa4c1c5a1cd7e39d9aa00f8f1a90efe Mon Sep 17 00:00:00 2001 From: Victor Ikpeba Date: Wed, 31 Jan 2024 12:09:15 +0000 Subject: [PATCH 06/11] removed unwanted timezone in params --- src/Countries/Ghana.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Countries/Ghana.php b/src/Countries/Ghana.php index a272623d6..609a7224c 100644 --- a/src/Countries/Ghana.php +++ b/src/Countries/Ghana.php @@ -50,7 +50,7 @@ protected function christmasDay(int $year): array protected function boxingDay(int $year): array { $christmasDay = $this->getChristmasDay($year); - $boxingDay = new CarbonImmutable($year . "-12-26", $this->timezone); + $boxingDay = new CarbonImmutable($year . "-12-26"); $key = 'Boxing Day'; if ($christmasDay->isFriday()) { From e05af998be28da61855efb1fc208dd30b50d2729 Mon Sep 17 00:00:00 2001 From: Victor Ikpeba Date: Wed, 31 Jan 2024 16:40:38 +0000 Subject: [PATCH 07/11] removed timezone --- src/Countries/Ghana.php | 63 +++++++------------ .../it_can_calculate_ghana_holidays.snap | 6 +- 2 files changed, 26 insertions(+), 43 deletions(-) diff --git a/src/Countries/Ghana.php b/src/Countries/Ghana.php index 609a7224c..cc0f977ce 100644 --- a/src/Countries/Ghana.php +++ b/src/Countries/Ghana.php @@ -6,9 +6,6 @@ class Ghana extends Country { - - protected string $timezone = 'Africa/Accra'; - public function countryCode(): string { return 'gh'; @@ -16,88 +13,74 @@ public function countryCode(): string /** * Return carbon date for christmas + * * @return CarbonImmutable */ protected function getChristmasDay(int $year) { - return new CarbonImmutable($year . "-12-25"); + return new CarbonImmutable($year . '-12-25'); } - /** - * @return array - */ - protected function christmasDay(int $year): array + protected function christmasDay(int $year): CarbonImmutable { $christmasDay = $this->getChristmasDay($year); - $key = 'Christmas Day'; if ($christmasDay->isSaturday()) { - $key .= ' (substitute day)'; + $christmasDay = $christmasDay->next('monday'); } if ($christmasDay->isSunday()) { - $key .= ' (substitute day)'; $christmasDay = $christmasDay->next('tuesday'); } - return [$key => $christmasDay]; + return $christmasDay; } - /** - * @return array - */ - protected function boxingDay(int $year): array + protected function boxingDay(int $year): CarbonImmutable { $christmasDay = $this->getChristmasDay($year); - $boxingDay = new CarbonImmutable($year . "-12-26"); - $key = 'Boxing Day'; + $boxingDay = new CarbonImmutable($year . '-12-26'); if ($christmasDay->isFriday()) { - $key .= ' (substitute day)'; $boxingDay = $boxingDay->next('monday'); } - if ($christmasDay->isSaturday()) { - $key .= ' (substitute day)'; $boxingDay = $boxingDay->next('tuesday'); } - return [$key => $boxingDay]; + return $boxingDay; } /** * Get holiday - * - * If it falls on a weekend, the new day to be observed is the next monday - * - * @return array * + * For example: If a holiday falls on a weekend, the new day to be observed is the next monday */ - protected function getHoliday(string $nameOfHoliday, int $year, string $monthAndDay): array + protected function getHoliday(int $year, string $monthAndDay): CarbonImmutable { - $newYearsDay = new CarbonImmutable($year . "-" . $monthAndDay, $this->timezone); - $key = $nameOfHoliday; + $newYearsDay = new CarbonImmutable($year . '-' . $monthAndDay); if ($newYearsDay->isWeekend()) { - $key .= ' (substitute day)'; $newYearsDay = $newYearsDay->next('monday'); } - return [$key => $newYearsDay]; + return $newYearsDay; } protected function allHolidays(int $year): array { return array_merge( - $this->getHoliday('New Year Day', $year, "01-01"), - $this->getHoliday('Constitution Day', $year, "01-07"), - $this->getHoliday('Independence Day', $year, "03-06"), - $this->getHoliday('May Day', $year, "05-01"), - $this->getHoliday('Founders Day', $year, "08-04"), - $this->getHoliday('Kwame Nkrumah Memorial Day', $year, "09-21"), - $this->christmasDay($year), - $this->boxingDay($year), + [ + 'New Year Day' => $this->getHoliday($year, '01-01'), + 'Constitution Day' => $this->getHoliday($year, '01-07'), + 'Independence Day' => $this->getHoliday($year, '03-06'), + 'May Day' => $this->getHoliday($year, '05-01'), + 'Founders Day' => $this->getHoliday($year, '08-04'), + 'Kwame Nkrumah Memorial Day' => $this->getHoliday($year, '09-21'), + 'Christmas Day' => $this->christmasDay($year), + 'Boxing Day' => $this->boxingDay($year), + ], $this->variableHolidays($year) ); } @@ -107,7 +90,7 @@ protected function variableHolidays(int $year): array { $easter = $this->easter($year); - $farmersDay = (new CarbonImmutable('first friday of December ' . $year, $this->timezone)); + $farmersDay = new CarbonImmutable('first friday of December ' . $year); return [ 'Farmers Day' => $farmersDay, diff --git a/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_ghana_holidays.snap b/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_ghana_holidays.snap index 3109f1842..2fc3c6a72 100644 --- a/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_ghana_holidays.snap +++ b/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_ghana_holidays.snap @@ -4,7 +4,7 @@ "date": "2024-01-01" }, { - "name": "Constitution Day (substitute day)", + "name": "Constitution Day", "date": "2024-01-08" }, { @@ -24,11 +24,11 @@ "date": "2024-05-01" }, { - "name": "Founders Day (substitute day)", + "name": "Founders Day", "date": "2024-08-05" }, { - "name": "Kwame Nkrumah Memorial Day (substitute day)", + "name": "Kwame Nkrumah Memorial Day", "date": "2024-09-23" }, { From 0de850558f08a9126fd7dcb6fbb4bf2f5fa577c0 Mon Sep 17 00:00:00 2001 From: Victor Ikpeba Date: Thu, 1 Feb 2024 08:09:55 +0000 Subject: [PATCH 08/11] Updated test --- ...n_calculate_Ghana_date_based_regional_holidays.snap | 10 +++++++--- ...n_calculate_Ghana_easter_based_region_holidays.snap | 10 +++++++--- .../GhanaTest/it_can_calculate_ghana_holidays.snap | 4 ++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_date_based_regional_holidays.snap b/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_date_based_regional_holidays.snap index 3d29c9e8f..b5d9a6c72 100644 --- a/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_date_based_regional_holidays.snap +++ b/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_date_based_regional_holidays.snap @@ -5,7 +5,7 @@ }, { "name": "Constitution Day", - "date": "2024-01-07" + "date": "2024-01-08" }, { "name": "Independence Day", @@ -25,11 +25,15 @@ }, { "name": "Founder's Day", - "date": "2024-08-04" + "date": "2024-08-05" }, { "name": "Kwame Nkrumah Memorial Day", - "date": "2024-09-21" + "date": "2024-09-23" + }, + { + "name": "Farmers Day", + "date": "2024-12-06" }, { "name": "Christmas Day", diff --git a/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_easter_based_region_holidays.snap b/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_easter_based_region_holidays.snap index 3d29c9e8f..b5d9a6c72 100644 --- a/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_easter_based_region_holidays.snap +++ b/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_easter_based_region_holidays.snap @@ -5,7 +5,7 @@ }, { "name": "Constitution Day", - "date": "2024-01-07" + "date": "2024-01-08" }, { "name": "Independence Day", @@ -25,11 +25,15 @@ }, { "name": "Founder's Day", - "date": "2024-08-04" + "date": "2024-08-05" }, { "name": "Kwame Nkrumah Memorial Day", - "date": "2024-09-21" + "date": "2024-09-23" + }, + { + "name": "Farmers Day", + "date": "2024-12-06" }, { "name": "Christmas Day", diff --git a/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_ghana_holidays.snap b/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_ghana_holidays.snap index 2fc3c6a72..b5d9a6c72 100644 --- a/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_ghana_holidays.snap +++ b/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_ghana_holidays.snap @@ -1,6 +1,6 @@ [ { - "name": "New Year Day", + "name": "New Year's Day", "date": "2024-01-01" }, { @@ -24,7 +24,7 @@ "date": "2024-05-01" }, { - "name": "Founders Day", + "name": "Founder's Day", "date": "2024-08-05" }, { From 40fe26b0e02af28e610b441ae45d49cc9cd1b9f5 Mon Sep 17 00:00:00 2001 From: Victor Ikpeba Date: Thu, 1 Feb 2024 08:13:02 +0000 Subject: [PATCH 09/11] removed test files --- ...te_Ghana_date_based_regional_holidays.snap | 46 ------------------- ...te_Ghana_easter_based_region_holidays.snap | 46 ------------------- .../it_can_calculate_Ghana_holidays.snap | 42 ----------------- .../it_can_calculate_ghana_holidays.snap | 46 ------------------- 4 files changed, 180 deletions(-) delete mode 100644 tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_date_based_regional_holidays.snap delete mode 100644 tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_easter_based_region_holidays.snap delete mode 100644 tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_holidays.snap delete mode 100644 tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_ghana_holidays.snap diff --git a/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_date_based_regional_holidays.snap b/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_date_based_regional_holidays.snap deleted file mode 100644 index b5d9a6c72..000000000 --- a/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_date_based_regional_holidays.snap +++ /dev/null @@ -1,46 +0,0 @@ -[ - { - "name": "New Year's Day", - "date": "2024-01-01" - }, - { - "name": "Constitution Day", - "date": "2024-01-08" - }, - { - "name": "Independence Day", - "date": "2024-03-06" - }, - { - "name": "Good Friday", - "date": "2024-03-29" - }, - { - "name": "Easter Monday", - "date": "2024-04-01" - }, - { - "name": "May Day", - "date": "2024-05-01" - }, - { - "name": "Founder's Day", - "date": "2024-08-05" - }, - { - "name": "Kwame Nkrumah Memorial Day", - "date": "2024-09-23" - }, - { - "name": "Farmers Day", - "date": "2024-12-06" - }, - { - "name": "Christmas Day", - "date": "2024-12-25" - }, - { - "name": "Boxing Day", - "date": "2024-12-26" - } -] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_easter_based_region_holidays.snap b/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_easter_based_region_holidays.snap deleted file mode 100644 index b5d9a6c72..000000000 --- a/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_easter_based_region_holidays.snap +++ /dev/null @@ -1,46 +0,0 @@ -[ - { - "name": "New Year's Day", - "date": "2024-01-01" - }, - { - "name": "Constitution Day", - "date": "2024-01-08" - }, - { - "name": "Independence Day", - "date": "2024-03-06" - }, - { - "name": "Good Friday", - "date": "2024-03-29" - }, - { - "name": "Easter Monday", - "date": "2024-04-01" - }, - { - "name": "May Day", - "date": "2024-05-01" - }, - { - "name": "Founder's Day", - "date": "2024-08-05" - }, - { - "name": "Kwame Nkrumah Memorial Day", - "date": "2024-09-23" - }, - { - "name": "Farmers Day", - "date": "2024-12-06" - }, - { - "name": "Christmas Day", - "date": "2024-12-25" - }, - { - "name": "Boxing Day", - "date": "2024-12-26" - } -] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_holidays.snap b/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_holidays.snap deleted file mode 100644 index 3d29c9e8f..000000000 --- a/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_holidays.snap +++ /dev/null @@ -1,42 +0,0 @@ -[ - { - "name": "New Year's Day", - "date": "2024-01-01" - }, - { - "name": "Constitution Day", - "date": "2024-01-07" - }, - { - "name": "Independence Day", - "date": "2024-03-06" - }, - { - "name": "Good Friday", - "date": "2024-03-29" - }, - { - "name": "Easter Monday", - "date": "2024-04-01" - }, - { - "name": "May Day", - "date": "2024-05-01" - }, - { - "name": "Founder's Day", - "date": "2024-08-04" - }, - { - "name": "Kwame Nkrumah Memorial Day", - "date": "2024-09-21" - }, - { - "name": "Christmas Day", - "date": "2024-12-25" - }, - { - "name": "Boxing Day", - "date": "2024-12-26" - } -] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_ghana_holidays.snap b/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_ghana_holidays.snap deleted file mode 100644 index b5d9a6c72..000000000 --- a/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_ghana_holidays.snap +++ /dev/null @@ -1,46 +0,0 @@ -[ - { - "name": "New Year's Day", - "date": "2024-01-01" - }, - { - "name": "Constitution Day", - "date": "2024-01-08" - }, - { - "name": "Independence Day", - "date": "2024-03-06" - }, - { - "name": "Good Friday", - "date": "2024-03-29" - }, - { - "name": "Easter Monday", - "date": "2024-04-01" - }, - { - "name": "May Day", - "date": "2024-05-01" - }, - { - "name": "Founder's Day", - "date": "2024-08-05" - }, - { - "name": "Kwame Nkrumah Memorial Day", - "date": "2024-09-23" - }, - { - "name": "Farmers Day", - "date": "2024-12-06" - }, - { - "name": "Christmas Day", - "date": "2024-12-25" - }, - { - "name": "Boxing Day", - "date": "2024-12-26" - } -] \ No newline at end of file From 2013258525f2b3429773fd03595ca8a73ff5d7bf Mon Sep 17 00:00:00 2001 From: Victor Ikpeba Date: Thu, 1 Feb 2024 08:13:19 +0000 Subject: [PATCH 10/11] Add back test files --- ...te_Ghana_date_based_regional_holidays.snap | 46 +++++++++++++++++++ ...te_Ghana_easter_based_region_holidays.snap | 46 +++++++++++++++++++ .../it_can_calculate_Ghana_holidays.snap | 46 +++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_date_based_regional_holidays.snap create mode 100644 tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_easter_based_region_holidays.snap create mode 100644 tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_holidays.snap diff --git a/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_date_based_regional_holidays.snap b/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_date_based_regional_holidays.snap new file mode 100644 index 000000000..b5d9a6c72 --- /dev/null +++ b/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_date_based_regional_holidays.snap @@ -0,0 +1,46 @@ +[ + { + "name": "New Year's Day", + "date": "2024-01-01" + }, + { + "name": "Constitution Day", + "date": "2024-01-08" + }, + { + "name": "Independence Day", + "date": "2024-03-06" + }, + { + "name": "Good Friday", + "date": "2024-03-29" + }, + { + "name": "Easter Monday", + "date": "2024-04-01" + }, + { + "name": "May Day", + "date": "2024-05-01" + }, + { + "name": "Founder's Day", + "date": "2024-08-05" + }, + { + "name": "Kwame Nkrumah Memorial Day", + "date": "2024-09-23" + }, + { + "name": "Farmers Day", + "date": "2024-12-06" + }, + { + "name": "Christmas Day", + "date": "2024-12-25" + }, + { + "name": "Boxing Day", + "date": "2024-12-26" + } +] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_easter_based_region_holidays.snap b/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_easter_based_region_holidays.snap new file mode 100644 index 000000000..b5d9a6c72 --- /dev/null +++ b/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_easter_based_region_holidays.snap @@ -0,0 +1,46 @@ +[ + { + "name": "New Year's Day", + "date": "2024-01-01" + }, + { + "name": "Constitution Day", + "date": "2024-01-08" + }, + { + "name": "Independence Day", + "date": "2024-03-06" + }, + { + "name": "Good Friday", + "date": "2024-03-29" + }, + { + "name": "Easter Monday", + "date": "2024-04-01" + }, + { + "name": "May Day", + "date": "2024-05-01" + }, + { + "name": "Founder's Day", + "date": "2024-08-05" + }, + { + "name": "Kwame Nkrumah Memorial Day", + "date": "2024-09-23" + }, + { + "name": "Farmers Day", + "date": "2024-12-06" + }, + { + "name": "Christmas Day", + "date": "2024-12-25" + }, + { + "name": "Boxing Day", + "date": "2024-12-26" + } +] \ No newline at end of file diff --git a/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_holidays.snap b/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_holidays.snap new file mode 100644 index 000000000..b5d9a6c72 --- /dev/null +++ b/tests/.pest/snapshots/Countries/GhanaTest/it_can_calculate_Ghana_holidays.snap @@ -0,0 +1,46 @@ +[ + { + "name": "New Year's Day", + "date": "2024-01-01" + }, + { + "name": "Constitution Day", + "date": "2024-01-08" + }, + { + "name": "Independence Day", + "date": "2024-03-06" + }, + { + "name": "Good Friday", + "date": "2024-03-29" + }, + { + "name": "Easter Monday", + "date": "2024-04-01" + }, + { + "name": "May Day", + "date": "2024-05-01" + }, + { + "name": "Founder's Day", + "date": "2024-08-05" + }, + { + "name": "Kwame Nkrumah Memorial Day", + "date": "2024-09-23" + }, + { + "name": "Farmers Day", + "date": "2024-12-06" + }, + { + "name": "Christmas Day", + "date": "2024-12-25" + }, + { + "name": "Boxing Day", + "date": "2024-12-26" + } +] \ No newline at end of file From 38f9439ab742404da484b97846adb0727327f108 Mon Sep 17 00:00:00 2001 From: Victor Ikpeba Date: Thu, 8 Feb 2024 09:21:45 +0000 Subject: [PATCH 11/11] Added return types to methods --- src/Countries/Ghana.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Countries/Ghana.php b/src/Countries/Ghana.php index 6d28e4158..505677c36 100644 --- a/src/Countries/Ghana.php +++ b/src/Countries/Ghana.php @@ -21,6 +21,7 @@ protected function getChristmasDay(int $year) return new CarbonImmutable($year . '-12-25'); } + /** @return CarbonImmutable */ protected function christmasDay(int $year): CarbonImmutable { $christmasDay = $this->getChristmasDay($year); @@ -37,6 +38,7 @@ protected function christmasDay(int $year): CarbonImmutable return $christmasDay; } + /** @return CarbonImmutable */ protected function boxingDay(int $year): CarbonImmutable { $christmasDay = $this->getChristmasDay($year); @@ -56,6 +58,7 @@ protected function boxingDay(int $year): CarbonImmutable * Get holiday * * For example: If a holiday falls on a weekend, the new day to be observed is the next monday + * @return CarbonImmutable */ protected function getHoliday(int $year, string $monthAndDay): CarbonImmutable {