libtelex/telex-2
Composer 安装命令:
composer require libtelex/telex-2
包简介
Telephone numbers matched, validated, formatted, using PHP
README 文档
README
Telephone numbers matched, validated, formatted, using PHP.
Warning
TELEX-2 is a work in progress and does not yet offer the same functionality as its earlier incarnation, Telex
Warning
Only a small selection of European countries is supported at present—find out which ones by looking in src/RuleSet—and the rule-sets that have been implemented may not correctly recognise all of the country's numbers.
TELEX-2 is used by SeeTheWorld.
Usage
Quickly format a telephone number:
echo (new Telex2())->formatIntl('+44 (0)785 056 6978'); // => `"+44 7850 566978"`
Or get a complete rundown:
$telex2 = new Telex2(); print_r($telex2->match('+44 (0)785 056 6978')); /* => Libtelex\Telex2\TelephoneNumber Object ( [source:Libtelex\Telex2\TelephoneNumber:private] => +44 (0)785 056 6978 [countryCallingCode:Libtelex\Telex2\TelephoneNumber:private] => 44 [isoAlpha2CountryCode:Libtelex\Telex2\TelephoneNumber:private] => GB [nationalNumber:Libtelex\Telex2\TelephoneNumber:private] => 07850566978 [type:Libtelex\Telex2\TelephoneNumber:private] => 2 [formatted:Libtelex\Telex2\TelephoneNumber:private] => +44 7850 566978 ) */
Installation
Install using Composer:
composer require libtelex/telex-2
Background
TELEX-2 is yet another attempt at recognising, and formatting, telephone numbers using PHP; it is an evolution of Telex, which does a slightly better job than some much older, messier code.
TELEX-2 more reliably matches telephone numbers because it looks for more country-specific, numeric 'signatures'. These signatures, patterns in a country's telephone numbering plan, are encoded in separate rule-set classes—one for each country.
It's all still pretty rudimentary, really, but this latest incarnation is more robust and reliable, and its approach is much more satisfying than Telex'.
统计信息
- 总下载量: 257
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: ISC
- 更新时间: 2025-04-08