GithubHelp home page GithubHelp logo

janklewicz / php-library-holiday Goto Github PK

View Code? Open in Web Editor NEW

This project forked from michalmanko/php-library-holiday

0.0 1.0 0.0 322 KB

PHP Holiday Calculation Library

License: MIT License

PHP 100.00%

php-library-holiday's Introduction

Michalmanko/Holiday

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.

php-library-holiday's People

Contributors

adamschoenemann avatar aripringle avatar lsv avatar michalmanko avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.