michalmanko/php-library-holiday

A library to calculate holidays

1.1.0 2015-05-31 00:32 UTC

This package is not auto-updated.

Last update: 2024-03-26 01:02:20 UTC


README

Build Status Scrutinizer Code Quality Code Coverage Dependency Status

Latest Stable Version Latest Unstable Version

License Total Downloads Monthly Downloads

Michalmanko/Holiday is a small library to check if a specified date is a holiday in a specific country.

Requirements

Michalmanko/Holiday requires PHP 5.3.23 or later.

Installation

Composer

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"
    }
}

Manually

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.

Usage

Get a provider

$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.

Check holidays

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.

License

Michalmanko\Holiday is licensed under the MIT License, see the LICENSE.md file for more details.

Changelog

See the CHANGELOG.md file for more details.

Contributing

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.

Running Tests

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.