From a0666fbd7f52648d25941bd9ad303c0c7cc70279 Mon Sep 17 00:00:00 2001 From: Javier Emmanuel Mercedes Date: Wed, 17 Jan 2024 21:00:39 -0400 Subject: [PATCH 1/4] Added Dominican Republic holidays --- src/Countries/DominicanRepublic.php | 42 ++++++++++++++++ ...calculate_dominican_republic_holidays.snap | 50 +++++++++++++++++++ tests/Countries/DominicanRepublicTest.php | 19 +++++++ 3 files changed, 111 insertions(+) create mode 100644 src/Countries/DominicanRepublic.php create mode 100644 tests/.pest/snapshots/Countries/DominicanRepublicTest/it_can_calculate_dominican_republic_holidays.snap create mode 100644 tests/Countries/DominicanRepublicTest.php diff --git a/src/Countries/DominicanRepublic.php b/src/Countries/DominicanRepublic.php new file mode 100644 index 000000000..98cb24a77 --- /dev/null +++ b/src/Countries/DominicanRepublic.php @@ -0,0 +1,42 @@ + */ + protected function allHolidays(int $year): array + { + return array_merge([ + 'Año Nuevo' => '01-01', + 'Día de la Altagracia' => '01-21', + 'Día de Duarte' => '01-26', + 'Día de la Independencia' => '02-27', + 'Día del Trabajo' => '05-01', + 'Día de la Restauración' => '08-16', + 'Día de las Mercedes' => '09-24', + 'Día de la Constitución' => '11-06', + 'Día de la Virgen de la Altagracia' => '12-08', + 'Navidad' => '12-25', + ], $this->variableHolidays($year)); + } + + /** @return array */ + protected function variableHolidays(int $year): array + { + $easter = CarbonImmutable::createFromTimestamp(easter_date($year)) + ->setTimezone('America/Santo_Domingo'); + + return [ + 'Jueves Santo' => $easter->subDays(3), + 'Viernes Santo' => $easter->subDays(2), + ]; + } +} diff --git a/tests/.pest/snapshots/Countries/DominicanRepublicTest/it_can_calculate_dominican_republic_holidays.snap b/tests/.pest/snapshots/Countries/DominicanRepublicTest/it_can_calculate_dominican_republic_holidays.snap new file mode 100644 index 000000000..163490da2 --- /dev/null +++ b/tests/.pest/snapshots/Countries/DominicanRepublicTest/it_can_calculate_dominican_republic_holidays.snap @@ -0,0 +1,50 @@ +[ + { + "name": "A\u00f1o Nuevo", + "date": "2024-01-01" + }, + { + "name": "D\u00eda de la Altagracia", + "date": "2024-01-21" + }, + { + "name": "D\u00eda de Duarte", + "date": "2024-01-26" + }, + { + "name": "D\u00eda de la Independencia", + "date": "2024-02-27" + }, + { + "name": "Jueves Santo", + "date": "2024-03-28" + }, + { + "name": "Viernes Santo", + "date": "2024-03-29" + }, + { + "name": "D\u00eda del Trabajo", + "date": "2024-05-01" + }, + { + "name": "D\u00eda de la Restauraci\u00f3n", + "date": "2024-08-16" + }, + { + "name": "D\u00eda de las Mercedes", + "date": "2024-09-24" + }, + { + "name": "D\u00eda de la Constituci\u00f3n", + "date": "2024-11-06" + }, + { + "name": "D\u00eda de la Virgen de la Altagracia", + "date": "2024-12-08" + }, + { + "name": "Navidad", + "date": "2024-12-25" + } +] \ No newline at end of file diff --git a/tests/Countries/DominicanRepublicTest.php b/tests/Countries/DominicanRepublicTest.php new file mode 100644 index 000000000..7a388eda6 --- /dev/null +++ b/tests/Countries/DominicanRepublicTest.php @@ -0,0 +1,19 @@ +get(); + + expect($holidays) + ->toBeArray() + ->not()->toBeEmpty(); + + expect(formatDates($holidays))->toMatchSnapshot(); +}); + From 47c40bfd3344e91a5e23c93e7aae92c35f833870 Mon Sep 17 00:00:00 2001 From: Javier Emmanuel Mercedes Date: Thu, 18 Jan 2024 11:59:02 -0400 Subject: [PATCH 2/4] Removed lines --- src/Countries/DominicanRepublic.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Countries/DominicanRepublic.php b/src/Countries/DominicanRepublic.php index 98cb24a77..ea9659846 100644 --- a/src/Countries/DominicanRepublic.php +++ b/src/Countries/DominicanRepublic.php @@ -10,8 +10,6 @@ public function countryCode(): string { return 'do'; } - - /** @return array */ protected function allHolidays(int $year): array { return array_merge([ @@ -27,8 +25,6 @@ protected function allHolidays(int $year): array 'Navidad' => '12-25', ], $this->variableHolidays($year)); } - - /** @return array */ protected function variableHolidays(int $year): array { $easter = CarbonImmutable::createFromTimestamp(easter_date($year)) From 1c865ad771b07b1a31153965a48e5dc4889212ca Mon Sep 17 00:00:00 2001 From: Javier Emmanuel Mercedes Date: Thu, 18 Jan 2024 12:02:56 -0400 Subject: [PATCH 3/4] Added comments for phpstan --- src/Countries/DominicanRepublic.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Countries/DominicanRepublic.php b/src/Countries/DominicanRepublic.php index ea9659846..98cb24a77 100644 --- a/src/Countries/DominicanRepublic.php +++ b/src/Countries/DominicanRepublic.php @@ -10,6 +10,8 @@ public function countryCode(): string { return 'do'; } + + /** @return array */ protected function allHolidays(int $year): array { return array_merge([ @@ -25,6 +27,8 @@ protected function allHolidays(int $year): array 'Navidad' => '12-25', ], $this->variableHolidays($year)); } + + /** @return array */ protected function variableHolidays(int $year): array { $easter = CarbonImmutable::createFromTimestamp(easter_date($year)) From d30d0562eaf2618f2e659695f6a1269cefcdefec Mon Sep 17 00:00:00 2001 From: Javier Emmanuel Mercedes Date: Fri, 19 Jan 2024 20:06:27 -0400 Subject: [PATCH 4/4] Fixed non national holiday --- src/Countries/DominicanRepublic.php | 15 +-------------- ...can_calculate_dominican_republic_holidays.snap | 12 ------------ 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/src/Countries/DominicanRepublic.php b/src/Countries/DominicanRepublic.php index 98cb24a77..c632ae430 100644 --- a/src/Countries/DominicanRepublic.php +++ b/src/Countries/DominicanRepublic.php @@ -14,7 +14,7 @@ public function countryCode(): string /** @return array */ protected function allHolidays(int $year): array { - return array_merge([ + return [ 'Año Nuevo' => '01-01', 'Día de la Altagracia' => '01-21', 'Día de Duarte' => '01-26', @@ -23,20 +23,7 @@ protected function allHolidays(int $year): array 'Día de la Restauración' => '08-16', 'Día de las Mercedes' => '09-24', 'Día de la Constitución' => '11-06', - 'Día de la Virgen de la Altagracia' => '12-08', 'Navidad' => '12-25', - ], $this->variableHolidays($year)); - } - - /** @return array */ - protected function variableHolidays(int $year): array - { - $easter = CarbonImmutable::createFromTimestamp(easter_date($year)) - ->setTimezone('America/Santo_Domingo'); - - return [ - 'Jueves Santo' => $easter->subDays(3), - 'Viernes Santo' => $easter->subDays(2), ]; } } diff --git a/tests/.pest/snapshots/Countries/DominicanRepublicTest/it_can_calculate_dominican_republic_holidays.snap b/tests/.pest/snapshots/Countries/DominicanRepublicTest/it_can_calculate_dominican_republic_holidays.snap index 163490da2..3bdd36d0d 100644 --- a/tests/.pest/snapshots/Countries/DominicanRepublicTest/it_can_calculate_dominican_republic_holidays.snap +++ b/tests/.pest/snapshots/Countries/DominicanRepublicTest/it_can_calculate_dominican_republic_holidays.snap @@ -15,14 +15,6 @@ "name": "D\u00eda de la Independencia", "date": "2024-02-27" }, - { - "name": "Jueves Santo", - "date": "2024-03-28" - }, - { - "name": "Viernes Santo", - "date": "2024-03-29" - }, { "name": "D\u00eda del Trabajo", "date": "2024-05-01" @@ -39,10 +31,6 @@ "name": "D\u00eda de la Constituci\u00f3n", "date": "2024-11-06" }, - { - "name": "D\u00eda de la Virgen de la Altagracia", - "date": "2024-12-08" - }, { "name": "Navidad", "date": "2024-12-25"