diff --git a/src/Countries/Philippines.php b/src/Countries/Philippines.php new file mode 100644 index 000000000..dd4cf848e --- /dev/null +++ b/src/Countries/Philippines.php @@ -0,0 +1,41 @@ + '01-01', + 'Araw ng Kagitingan' => '04-09', + 'Labor Day' => '05-01', + 'Independence Day' => '06-12', + 'Bonifacio Day' => '11-27', + 'Christmas Day' => '12-25', + 'Rizal Day' => '12-30', + ], $this->variableHolidays($year)); + } + + /** @return array */ + protected function variableHolidays(int $year): array + { + $nationalHeroes = new CarbonImmutable("last monday of august {$year}"); + + $easter = CarbonImmutable::createFromTimestamp(easter_date($year)) + ->setTimezone('Asia/Manila'); + + return [ + 'Maundy Thursday' => $easter->subDays(3), + 'Good Friday' => $easter->subDays(2), + 'National Heroes Day' => $nationalHeroes, + ]; + } +} diff --git a/tests/.pest/snapshots/Countries/PhilippinesTest/it_can_calculate_philippine_holidays.snap b/tests/.pest/snapshots/Countries/PhilippinesTest/it_can_calculate_philippine_holidays.snap new file mode 100644 index 000000000..0859fcf5e --- /dev/null +++ b/tests/.pest/snapshots/Countries/PhilippinesTest/it_can_calculate_philippine_holidays.snap @@ -0,0 +1,42 @@ +[ + { + "name": "New Year's Day", + "date": "2024-01-01" + }, + { + "name": "Maundy Thursday", + "date": "2024-03-28" + }, + { + "name": "Good Friday", + "date": "2024-03-29" + }, + { + "name": "Araw ng Kagitingan", + "date": "2024-04-09" + }, + { + "name": "Labor Day", + "date": "2024-05-01" + }, + { + "name": "Independence Day", + "date": "2024-06-12" + }, + { + "name": "National Heroes Day", + "date": "2024-08-26" + }, + { + "name": "Bonifacio Day", + "date": "2024-11-27" + }, + { + "name": "Christmas Day", + "date": "2024-12-25" + }, + { + "name": "Rizal Day", + "date": "2024-12-30" + } +] \ No newline at end of file diff --git a/tests/Countries/PhilippinesTest.php b/tests/Countries/PhilippinesTest.php new file mode 100644 index 000000000..4fd997173 --- /dev/null +++ b/tests/Countries/PhilippinesTest.php @@ -0,0 +1,19 @@ +get(); + + expect($holidays) + ->toBeArray() + ->not()->toBeEmpty(); + + expect(formatDates($holidays))->toMatchSnapshot(); + +});