tourze/gb-t-12406

0.0.1 2025-05-24 17:06 UTC

This package is auto-updated.

Last update: 2025-05-29 10:22:41 UTC


README

English | 中文

Latest Version Build Status Quality Score Total Downloads

A PHP package that implements the GB/T 12406 standard for currency codes, based on PHP 8.1+ enum, providing type-safe and convenient currency code handling.

Features

  • Full implementation of GB/T 12406 currency codes
  • Type-safe PHP 8.1+ enum
  • All currency codes and their English names
  • IDE autocompletion support
  • Easy conversion to array and label fetching

Installation

Requirements:

  • PHP 8.1 or above
  • Dependency: tourze/enum-extra >= 0.0.5

Install via Composer:

composer require tourze/gb-t-12406

Quick Start

use Tourze\GBT12406\Currency;

// Get currency code
$currency = Currency::CNY;

// Get currency English name
echo $currency->getLabel(); // Output: Chinese Yuan

// Get all available currencies
$allCurrencies = Currency::cases();

// Convert currency to array item
$item = Currency::CNY->toItem();
// [
//     'value' => 'CNY',
//     'label' => 'Chinese Yuan'
// ]

Documentation

  • All currency codes are provided as enum constants, with IDE completion
  • getLabel() gets the English name
  • toItem() converts to array, suitable for dropdowns, etc.
  • Relies on tourze/enum-extra for extended features

Contributing

Feel free to submit issues and PRs. Please follow PSR standards and ensure tests pass with PHPUnit before submitting.

License

MIT License © tourze

Changelog

See [CHANGELOG.md] or git history for details.