PHPackages                             hostlink/hk-public-holiday - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. hostlink/hk-public-holiday

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hostlink/hk-public-holiday
==========================

v1.1.0(1mo ago)016MITPHPPHP &gt;=8.1CI passing

Since Dec 12Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/HostLink/hk-public-holiday)[ Packagist](https://packagist.org/packages/hostlink/hk-public-holiday)[ RSS](/packages/hostlink-hk-public-holiday/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (5)Versions (4)Used By (0)

HK Public Holiday
=================

[](#hk-public-holiday)

[![Tests](https://github.com/HostLink/hk-public-holiday/actions/workflows/tests.yml/badge.svg)](https://github.com/HostLink/hk-public-holiday/actions/workflows/tests.yml)

This library provides functionality to check Hong Kong public holidays and manage holiday data caching.

Requirements
------------

[](#requirements)

- PHP &gt;= 8.1
- `symfony/cache` ^6.4, ^7.0, or ^8.0

Installation
------------

[](#installation)

To install the library, use Composer:

```
composer require hostlink/hk-public-holiday
```

Usage
-----

[](#usage)

### Initialization

[](#initialization)

To initialize the `Holiday` class, you can specify the language (`en`, `tc`, `sc`) and an optional PSR-6 cache pool.

```
use HostLink\Calendar\Holiday;

// en: English, tc: Traditional Chinese, sc: Simplified Chinese
$holiday = new Holiday("en");
```

By default, a `FilesystemAdapter` is used to cache holiday data. You can inject any PSR-6 `CacheItemPoolInterface` implementation:

```
use HostLink\Calendar\Holiday;
use Symfony\Component\Cache\Adapter\ArrayAdapter;

$holiday = new Holiday("en", new ArrayAdapter());
```

### Methods

[](#methods)

#### `clearCache()`

[](#clearcache)

Clears the cached holiday data for the current language.

```
$holiday->clearCache();
```

#### `getData()`

[](#getdata)

Fetches the holiday data. If not cached, downloads it from the internet and caches it for one month.

```
$data = $holiday->getData();
```

#### `isHoliday(string $date): bool`

[](#isholidaystring-date-bool)

Checks if a given date (in `YYYY-MM-DD` format) is a public holiday.

```
$isHoliday = $holiday->isHoliday("2023-12-25");
```

#### `getRange(string $from, string $to): array`

[](#getrangestring-from-string-to-array)

Gets all public holidays within a date range (inclusive, `YYYY-MM-DD` format).

```
$holidays = $holiday->getRange("2023-01-01", "2023-12-31");
```

### Example

[](#example)

```
use HostLink\Calendar\Holiday;

$holiday = new Holiday("en");

if ($holiday->isHoliday("2023-12-25")) {
    echo "It's a holiday!";
} else {
    echo "It's not a holiday.";
}

$holidays = $holiday->getRange("2023-01-01", "2023-12-31");
foreach ($holidays as $h) {
    echo $h["date"] . ": " . $h["name"] . "\n";
}
```

License
-------

[](#license)

This project is licensed under the MIT License.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance94

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~267 days

Total

3

Last Release

32d ago

PHP version history (2 changes)1.0.0PHP &gt;=8.0.0

v1.1.0PHP &gt;=8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/18732337?v=4)[Raymond](/maintainers/mathsgod)[@mathsgod](https://github.com/mathsgod)

---

Top Contributors

[![mathsgod](https://avatars.githubusercontent.com/u/18732337?v=4)](https://github.com/mathsgod "mathsgod (12 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hostlink-hk-public-holiday/health.svg)

```
[![Health](https://phpackages.com/badges/hostlink-hk-public-holiday/health.svg)](https://phpackages.com/packages/hostlink-hk-public-holiday)
```

###  Alternatives

[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M203](/packages/sulu-sulu)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)[psx/schema

Parse and generate data schema formats

57245.5k24](/packages/psx-schema)[oat-sa/generis

TAO generis library

10148.8k124](/packages/oat-sa-generis)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
