ronanguilloux/isocodes
Composer 安装命令:
composer require ronanguilloux/isocodes
包简介
PHP library - Validators for standards from ISO, International Finance, Public Administrations, GS1, Book and Music Industries, Phone numbers & Zipcodes for many countries
关键字:
README 文档
README
PHP library - Validators for standards from ISO, International Finance, Public Administrations, GS1, Book Industry, Phone numbers & Zipcodes for many countries
Usage
// Sending letters to the Labrador Islands ? $isCanadian = ZipCode::validate('A0A 1A0', 'CA'); // Checking out your e-commerce shopping cart? $isBankable = CreditCard::validate('12345679123456'); // Transferring money worldwide? $isSwiftBic = SwiftBic::validate('CEDELULLXXX'); // Paying your taxes in Madrid? $isTaxableInSpain = Nif::validate('A999999L'); // Receiving containers from Port of Shanghai? $isShippingContainerCode = Sscc::validate('806141411234567896'); // Publishing books? $isPublished = Isbn::validate('2-2110-4199-X') // Trading items with GTIN barcodes in GS1 system? $isBarcode = Ean13::validate('4719512002889') // Calling phone numbers in Palo Alto? $isPhonable = PhoneNumber::validate('+1-650-798-2800', 'US') // Buying Apple stocks? $isISIN = Isin::validate('US0378331005'); // Apple Inc. (AAPL) // Trading Apple products? $isCUSIP = Cusip::validate('037833100'); // Apple Inc. (AAPL) // Is this the unique digital fingerprint for for "Instant Crush" by Daft Punk? $isISRC = Isrc::validate('US-QX9-13-00105'); // Is this jazz band covering Daft Punk's "Around the World"? $isISWC = Iswc::validate('T-003.958.832-6'); // Checking your iPhone device is valid? $isDevice = Imei::validate('352066060926230'); // Selling your Honda Civic? $isVin = VinNA::validate('1HGBH41JXMN109186'); // Sending packages via DHL? $isIdentcode = Identcode::validate('563102430313'); $isLeitcode = Leitcode::validate('23669012012305');
ISO Codes Validations available:
International Finance
- IBAN (requires
bcmathPHP extension) - SWIFT/BIC
- BBAN (RIB, requires
bcmathPHP extension) - Credit Card number
- SEDOL (Stock Exchange codes)
Manufacturing Industries
- ISBN - International Standard Book Number, both 10 & 13 digits
- ISMN - International Standard Music Number
- ISSN - International Standard Serial Number
- IMO - International Maritime Organization (Ship Identification Number)
- ISWC - International Standard Musical Work Code
- IMEI - International Mobile Equipment Identity
- VIN - Vehicle Identification Number – ISO 3779 & ISO 4030
Public Administrations
- ISIN - International Securities Identification Number
- Country-specific VAT / tax system: various VAT number formats
- France: Numéro de Sécurité Sociale / INSEE, SIREN, SIRET, Codes postaux, Clef Type 1/2 Norme B2
- US: Social Security number
- UK: National Insurance Number (NINO)
- Belgium: Structured Ccommunication ("communication structurée")
- Spain: NIF, NIE (Número de Identificación Fiscal/Extranjero) & CIF (Código de identificación fiscal)
- Netherlands: Burgerservicenummer / Citizen Service Number (BSN)
- Finland: HETU, Henkilötunnus (Finnish personal identity code)
- Switzerland: Business Orgs UID (VAT) Number / Unternehmens-Identifikationsnummer
GS1 specific numbers/identifiers
- GTIN - Global Trade Item Number: GTIN-8, GTIN-12, GTIN-13, GTIN-14
- GLN - Global Location Number
- SSCC - Serial Shipping Container Code
- GRAI - Global Returnable Asset Identifier
- GSRN - Global Service Relation Number
- GDTI - Global Document Type Identifier
- UDI - Unique Device Identification (the GTIN part of it)
- Older/deprecated identifiers, now in GTIN: EAN-8, EAN-13, UCC-13, UPC-A, DUN-14, ITF-14
Logistics & Post
- Identcode (Deutsche Post DHL)
- Leitcode (Deutsche Post DHL)
Miscellaneous
- ZIP code validators for 175+ countries
- Phone number validation for all countries/regions of the world
Each code has its own validator. Each validator is illustrated by a unit test case.
IsoCodes is compatible with all versions of PHP that are actively supported by the PHP project.
Build status
Continously inspecting results (phpdoc, phpmd, phpcc, etc.) available on Scrutinizer CI
bcmath as an optional extension for certain validators
For IBAN & BBAN ISO-codes, PHP is required to be compiled with "--enable-bcmath" for arbitrary precision mathematic checks.
Usually, you already have bcmath bundled in your PHP version, since many common PHP packages (php-cli, php-fpm, php5-cgi, libapache2-mod-php5, etc.) in stable GNU/Linux distribution releases (such as Debian) are listed as having bcmath built in to them, as an included module.
Installing
Via GitHub
$ git clone git@github.com:ronanguilloux/IsoCodes.git
$ make # requires composer
Autoloading is PSR-0 friendly.
Via Packagist & Composer
Require the latest version of ronanguilloux/isocodes with Composer
$ composer require ronanguilloux/isocodes
Wrappers
With Symfony Validator
Install Soullivaneuh/IsoCodesValidator to get IsoCodes working as Validator for Symfony and Silex.
With CakePHP 3
Install gourmet/validation to get IsoCodes working with CakePHP 3 as a validator.
With Laravel
Install pixelpeter/laravel5-isocodes-validation to get IsoCodes working with Laravel 5 as a validator. Install pixelpeter/laravel-isocodes-validation to get IsoCodes working with Laravel 10+ as a validator.
Supported PHP versions
- till tags 2.3.9: PHP 7.*
- from tags 2.4.0: PHP 8.*
Unit testing
$ make tests
Make utilities
For development & contribution purpose only, a Makefile provides various tools to check your code style, quality & test coverage:
Usual tasks:
To initialize vendors: make
To check code quality: make quality
To run tests suite: make tests
To fix code style: make cs-fix
Other specific tasks:
To evaluate code coverage: make codecoverage
To run a simple continuous tests server: make continuous
To dry-fix code style issues: make dry-fix
To evaluate code quality stats: make stats
To update vendors using Composer: make update
Quality assurance report
Isocodes quality plan is mainly based on phpunit: it runs 980+ unit tests, with separated valid & invalid entry sets. Test values are mainly real data or documented examples from standard documentation, and a few handmade values.
The composer.json already includes these Php Quality Assurance Toolchain libraries:
Just run:
$ make stats -i
XML report outputs are then generated in a new ./build folder
Code covering report built using Coveralls.io. How-to generate such code coverage report using PHPUnit.
License Information
- GNU GPL v3
- You can find a copy of this software here: https://github.com/ronanguilloux/IsoCodes
Contributing Code
The issue queue can be found at: https://github.com/ronanguilloux/IsoCodes/issues. See CONTRIBUTING.md.
Special thanks
Contributors list: Many thanks to all!
Many thanks to JetBrains PhpStorm for having sponsored the IsoCode library development from the very beginning! Any contributor having an accepted PR may receive an Open Source License Key for PhpStorm IDE. Just ping Ronan via email to get one.
ronanguilloux/isocodes 适用场景与选型建议
ronanguilloux/isocodes 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.44M 次下载、GitHub Stars 达 803, 最近一次更新时间为 2012 年 10 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「validator」 「book」 「swift」 「vat」 「zipcode」 「standard」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ronanguilloux/isocodes 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ronanguilloux/isocodes 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ronanguilloux/isocodes 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Parse a generic mail stream, and convert it to a SwiftMailer Message
Runn Me! Validation and Sanitization Library
Extension for Opis JSON Schema
Book publishing application
PHP IBAN - This library provides a converter for account number, bank code and IBAN.
📇 PHP library for address book contacts (make vCards for contacts)
统计信息
- 总下载量: 3.44M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 811
- 点击次数: 38
- 依赖项目数: 26
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2012-10-13