automex / amex-license-plate-formatter-php

PHP 库,用于验证和格式化车牌号码。

v1.1.2 2022-02-12 22:43 UTC

This package is auto-updated.

Last update: 2024-09-13 05:05:29 UTC


README

All Contributors

此库可用于验证和格式化车牌号码。

支持的国家

欧洲

  • 比利时(1971至今)
  • 芬兰(1922至今)
  • 法国(1976至今)
  • 德国(未知日期至今)
  • 意大利(1994至今)
  • 卢森堡(未知日期至今)
  • 荷兰(1951至今)
  • 西班牙(1900至今)
  • 英国(1903至今)

非洲

  • 中非共和国(2006至今)
  • 加蓬(1962至今)

亚洲

  • 以色列(未知日期至今)

大洋洲

  • 新西兰(1964至今)

南美洲

  • 巴西(1990至今)

更多

  • 未来还将添加更多国家

如何安装

composer require automex/amex-license-plate-formatter-php

或者将以下内容添加到您的 composer.json 中

{
    "require": {
        "automex/amex-license-plate-formatter-php": "^1.0.0"
    }
}

如何使用

使用用户输入作为第一个参数调用您选择的车牌类构造函数

<?php
$licenseplate = new \Amex\LicensePlate\DutchLicensePlate('08ttnp');
if($licenseplate->isValid())
{
    echo $licenseplate->format(); // Outputs 08-TT-NP in this case
}

由于每个国家的车牌类都实现了 LicensePlateInterface 接口,因此它们公开了 isValid() 和 format() 方法。也可能有特定于国家的方法。请检查特定类的代码以获取完整信息。

请注意,此库不会检查车牌号是否真实存在,也不会排除不允许的组合。

许可证

代码和文档在 LPGLv2.1 许可证 下发布。

贡献者 ✨

感谢这些优秀的人们 (emoji key)

此项目遵循 all-contributors 规范。欢迎任何形式的贡献!