ixnode/php-public-holiday

This PHP package automatically generates holidays for a given year, considering both federal states and the country. It provides an easy-to-use interface to retrieve public holidays based on specific regions, ensuring accurate and up-to-date holiday information for all supported areas.

0.1.1 2024-07-18 22:03 UTC

This package is auto-updated.

Last update: 2024-11-18 22:42:18 UTC


README

Release PHP PHPStan PHPUnit PHPCS PHPMD Rector - Instant Upgrades and Automated Refactoring LICENSE

This PHP package automatically generates holidays for a given year, considering both federal states and the country. It provides an easy-to-use interface to retrieve public holidays based on specific regions, ensuring accurate and up-to-date holiday information for all supported areas.

1. Usage

use Ixnode\PhpPublicHoliday\Holiday;

1.1 Get the public holidays of Germany from the state of Saxony

$year = 2024;
$country = \Ixnode\PhpPublicHoliday\Configuration\Country::DE;
$state = \Ixnode\PhpPublicHoliday\Configuration\Country\CountryDe::STATE_SN;

$holiday = new Holiday($year, $country, $state);

print_r($holiday->getHolidays());
// (array) [Ixnode\PhpPublicHoliday\HolidayItem Object, ...]
// - (DateTimeImmutable) ->getDate()
// - (string) ->getName()

2. Installation

composer require ixnode/php-public-holiday
vendor/bin/php-public-holiday -V
php-public-holiday 0.1.0 (2024-07-18 20:33:58) - Björn Hempel <bjoern@hempel.li>

3. Command line tool

Used to quickly check the public holidays.

bin/console ph DE SN 2024

or within your composer project:

vendor/bin/php-public-holiday ph DE SN 2024
Country: DE
State:   SN
Year:    2024

- 2024-01-01: Neujahr
- 2024-03-29: Karfreitag
- 2024-03-31: Ostersonntag
- 2024-04-01: Ostermontag
- 2024-05-01: Tag der Arbeit
- 2024-05-09: Christi Himmelfahrt
- 2024-05-19: Pfingstsonntag
- 2024-05-20: Pfingstmontag
- 2024-10-03: Tag der deutschen Einheit
- 2024-12-25: Erster Weihnachtsfeiertag
- 2024-12-26: Zweiter Weihnachtsfeiertag

4. Library development

git clone git@github.com:ixnode/php-public-holiday.git && cd php-public-holiday
composer install
composer test

5. License

This library is licensed under the MIT License - see the LICENSE file for details.

6. Author