lizhineng/vehicle-license-china
最新稳定版本:v0.1.1
Composer 安装命令:
composer require lizhineng/vehicle-license-china
包简介
Vehicle license library for China.
README 文档
README
The library implements the GA 36-2018, which helps you validate the vehicle registration number issued in mainland China and extract the information from the plate number.
Install
The package can be installed through Composer and requires PHP 8.4+
composer require lizhineng/vehicle-license-china
Usage
You can easily create an instance of a registration number with the make
factory method. All validation will be checked against the plate number
before initialization; otherwise, a RegistrationNumberException will be
thrown.
use Zhineng\VehicleLicenseChina\RegistrationNumber; use Zhineng\VehicleLicenseChina\RegistrationNumberException; try { $registrationNumber = RegistrationNumber::make('粤E12345'); } catch (RegistrationNumberException $e) { // The registration number is invalid. }
The library supports all vehicle types defined in the standard: embassy, consulate, police, coach, trailer, Hong Kong, Macau, test, and special vehicles.
$registrationNumber->isEmbassy(); $registrationNumber->isConsulate(); $registrationNumber->isPolice(); $registrationNumber->isCoach(); $registrationNumber->isTrailer(); $registrationNumber->isFromHongKong(); $registrationNumber->isFromMacau(); $registrationNumber->isTest(); $registrationNumber->isSpecial();
To differentiate clean energy vehicles, note that these plate numbers apply only to those without any suffix.
$registrationNumber->isCleanEnergy(); // Check if it's a small clean energy vehicle $registrationNumber->isSmallCleanEnergy(); // Check if it's a large clean energy vehicle $registrationNumber->isLargeCleanEnergy();
You can further specify if a clean energy vehicle is entirely powered by electricity.
$registrationNumber->isBatteryElectric();
License
The library is released under the MIT license.
统计信息
- 总下载量: 41
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-05-14