tourze / gb-t-2659
GB/T 2659
0.0.2
2025-04-19 12:16 UTC
Requires
- php: ^8.1
- tourze/enum-extra: ~0.0.5
Requires (Dev)
- phpstan/phpstan: ^2.1
This package is auto-updated.
Last update: 2025-04-27 10:28:51 UTC
README
A PHP implementation of GB/T 2659 country and region codes (2-letter).
Features
- Complete implementation of GB/T 2659 standard
- Supports both Chinese and English country names
- Based on PHP 8.1 enums, type-safe
- Extensible and suitable for forms, data transformation, and more
Installation
- Requires PHP >= 8.1
- Depends on
tourze/enum-extra
Install via Composer:
composer require tourze/gb-t-2659
Quick Start
use Tourze\GBT2659\Alpha2Code; // Get country code $code = Alpha2Code::CN; // China $code = Alpha2Code::US; // United States // Get country name echo $code->getLabel(); // Output: China // Get lowercase code echo $code->toLowerCase(); // Output: cn
Documentation
- Retrieve all enum entries via
Alpha2Code::cases()
getLabel()
returns the country nametoLowerCase()
returns the lowercase code- Integrate with forms or dropdowns using
toArray()
ortoSelectItem()
Contributing
- Please check existing issues and PRs before submitting new ones
- Follow the coding style and provide tests for new features
License
MIT License
Changelog
See [CHANGELOG.md] or the Git commit history for details.