n11t/holidays
Composer 安装命令:
composer require n11t/holidays
包简介
Service to calculate Holidays
README 文档
README
Holidays
Object oriented service to calculate holidays between given dates or check if given date is holiday. Can be extended by own providers.
Installation
Installing via Composer (recommended)
composer require n11t/holidays
Usage
<?php
require_once __DIR__ . '/vendor/autoload.php';
$calculator = new \N11t\Holidays\Country\Germany();
// Check if date is holiday
$calculator->isHoliday(new \DateTime('2018-12-24')); // True
// Get Holidays in Range
$calculator->between(new \DateTime('2018-03-26'), new \DateTime('2018-04-02')); // 2018-03-30, 2018-04-02
// Extend calculation by own providers
$calculator->isHoliday(new \DateTime('2018-03-01')); // False
$calculator->addProvider(new FirstOfMarchProvider());
$calculator->isHoliday(new \DateTime('2018-03-01')); // True
class FirstOfMarchProvider implements \N11t\Holidays\Calculator\Provider\HolidayProvider {
public function getHolidays(int $year): \N11t\Holidays\Entity\HolidayCollection
{
$holidays = [
new \N11t\Holidays\Entity\Holiday('2018-03-01', 'Funny Holiday')
];
return new \N11t\Holidays\Entity\HolidayCollection(...$holidays);
}
}
Tipp: Always use the \N11t\Holidays\HolidayCalculator interface as type-hint.
Supported States
Currently Germany and it's states are Supported. Feel free to contribute.
统计信息
- 总下载量: 21
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-03-26