Michalmanko/Holiday is a small library to check if a specified date is a holiday in a specific country.
Michalmanko/Holiday requires PHP 5.3.23 or later.
The easiest way to install this library is through composer. Just add the following lines to your composer.json file:
{
"require": {
"michalmanko/php-library-holiday": "~1.1.0"
}
}
Another way would be to download this library and configure the autoloading yourself. This library relies on a PSR-4 compatible autoloader for automatic class loading.
$providerByIso = \Michalmanko\Holiday\HolidayFactory::createProvider('PL');
$providerByCountry = \Michalmanko\Holiday\HolidayFactory::createProvider('Poland');
$providerByClassName = \Michalmanko\Holiday\HolidayFactory::createProvider('\\Michalmanko\\Holiday\\Provider\\Poland');
You can select provider by two-letter ISO-3166-1 country codes, country name or just a class name.
To check for holidays just create the provider for specific country and call the getHolidays
method.
$provider = \Michalmanko\Holiday\HolidayFactory::createProvider('PL');
$holidays = $provider->getHolidays(new \DateTime('2014-01-01'));
If you just need to know if there is a holiday on your date or time period there are isHoliday
and hasHolidays
methods, too.
If you need to know all holidays for a specific country you can call the getHolidaysByYear
method.
Michalmanko\Holiday is licensed under the MIT License, see the LICENSE.md
file for more details.
See the CHANGELOG.md
file for more details.
Michalmanko/Holiday is open source. Everyone is more than welcome to contribute
more of them. If you use this library it would be great to get some support for currently not implemented countries which you are familiar with. Pull requests will be reviewed and merged fast.
To create a new Provider please see the \Michalmanko\Holiday\Provider\Poland
class as an example.
Run a php composer install
command in the base directory to install the phpunit
dependency. After that you can simply call vendor/bin/phpunit -c phpunit.xml.dist
to run the test suite.