PHPackages                             tourze/gb-t-12406 - 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. tourze/gb-t-12406

ActiveLibrary

tourze/gb-t-12406
=================

GB/T 12406

1.0.0(8mo ago)06821MITPHPCI passing

Since May 24Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/tourze/gb-t-12406)[ Packagist](https://packagist.org/packages/tourze/gb-t-12406)[ RSS](/packages/tourze-gb-t-12406/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (4)Versions (4)Used By (1)

GB/T 12406
==========

[](#gbt-12406)

[English](README.md) | [中文](README.zh-CN.md)

[![Latest Version](https://camo.githubusercontent.com/76f0baf31ce7dce3f425fd78b6ff904d2188dd9ba471cae25eb02d3f1ce5ead7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f75727a652f67622d742d31323430362e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/gb-t-12406)[![PHP Version Require](https://camo.githubusercontent.com/f68ac694eddd3f545a2ae5245e00991ee7648dac6b02f342596aa66c324b512a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f746f75727a652f67622d742d31323430362e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/gb-t-12406)[![License](https://camo.githubusercontent.com/4a8841bc192c64d13ff84620df8fec3de09bf0508957e7bef073120ac7ba5090/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746f75727a652f67622d742d31323430362e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/gb-t-12406)[![Build Status](https://camo.githubusercontent.com/be35db5f3096f4863d54d101919e7f83d192cd5c923649f341ee6129cfd4d378/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f746f75727a652f67622d742d31323430362f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/tourze/gb-t-12406)[![Quality Score](https://camo.githubusercontent.com/6987ee148c27c8188d607ec09d0156276476efac39d28945d177758317d1be1b/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f746f75727a652f67622d742d31323430362e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/tourze/gb-t-12406)[![Coverage Status](https://camo.githubusercontent.com/a0960f9567b0c3050b6a53188603acbade9b5bd310327b040426064754670ac6/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f746f75727a652f67622d742d31323430362f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/github/tourze/gb-t-12406?branch=master)[![Total Downloads](https://camo.githubusercontent.com/2362a0e8accad8a0d670a53e80a5583bf324944f8693df004d0abdb4853fce2a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f75727a652f67622d742d31323430362e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/gb-t-12406)

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
--------

[](#features)

- **Complete GB/T 12406 Implementation**: All 285 international currency codes
- **Type-safe PHP 8.1+ Enum**: Full IDE autocompletion and type safety
- **Multilingual Labels**: Chinese names for all currency codes
- **Flexible Data Export**: Multiple format support (array, select options)
- **Dynamic Configuration**: Environment-based option filtering
- **Historical Currency Support**: Includes deprecated currencies (DEM, FRF, etc.)
- **Framework Agnostic**: Works with any PHP framework or standalone

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

[](#installation)

**Requirements:**

- PHP 8.1 or above
- Dependency: `tourze/enum-extra` &gt;= 0.0.5

Install via Composer:

```
composer require tourze/gb-t-12406
```

Quick Start
-----------

[](#quick-start)

```
use Tourze\GBT12406\Currency;

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

// Get currency Chinese name
echo $currency->getLabel(); // Output: 人民币

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

// Convert currency to array item
$item = Currency::CNY->toArray();
// [
//     'value' => 'CNY',
//     'label' => '人民币'
// ]

// Convert to select item (for frontend)
$selectItem = Currency::CNY->toSelectItem();
// [
//     'value' => 'CNY',
//     'label' => '人民币',
//     'text' => '人民币',
//     'name' => '人民币'
// ]
```

API Reference
-------------

[](#api-reference)

### Basic Methods

[](#basic-methods)

- **`getLabel(): string`** - Get Chinese name of the currency
- **`toArray(): array`** - Convert to simple key-value array
- **`toSelectItem(): array`** - Convert to select option with multiple aliases
- **`Currency::cases(): array`** - Get all available currency enums
- **`Currency::from(string $value): Currency`** - Create enum from currency code
- **`Currency::tryFrom(string $value): ?Currency`** - Safe creation, returns null if invalid

### Advanced Features

[](#advanced-features)

#### Generate Options List

[](#generate-options-list)

```
// Generate all available options
$options = Currency::genOptions();
// Returns array of ['value' => 'CODE', 'label' => 'Name'] items
```

#### Dynamic Option Filtering

[](#dynamic-option-filtering)

```
// Disable specific currencies from options
$_ENV['enum-display:' . Currency::class . '-CNY'] = false;
$_ENV['enum-display:' . Currency::class . '-USD'] = false;

$filteredOptions = Currency::genOptions();
// CNY and USD will be excluded from the list
```

### Common Currency Examples

[](#common-currency-examples)

```
Currency::CNY->getLabel(); // "人民币"
Currency::USD->getLabel(); // "美元"
Currency::EUR->getLabel(); // "欧元"
Currency::JPY->getLabel(); // "日元"
Currency::GBP->getLabel(); // "英镑"
```

Extended Features
-----------------

[](#extended-features)

This package relies on `tourze/enum-extra` for:

- `Labelable` interface for label support
- `Itemable` interface for array conversion
- `Selectable` interface for option generation
- Dynamic configuration via environment variables

Contributing
------------

[](#contributing)

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

License
-------

[](#license)

MIT License © tourze

Changelog
---------

[](#changelog)

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

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance64

Regular maintenance activity

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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 ~80 days

Total

3

Last Release

244d ago

Major Versions

0.0.2 → 1.0.02025-11-01

### Community

Maintainers

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

---

Top Contributors

[![tourze](https://avatars.githubusercontent.com/u/13899502?v=4)](https://github.com/tourze "tourze (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-gb-t-12406/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-gb-t-12406/health.svg)](https://phpackages.com/packages/tourze-gb-t-12406)
```

PHPackages © 2026

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