fawkescreatives / myanmar-phone
本软件包用于在 Laravel 中构建易于使用的缅甸电话号码。
v1.2.0
2024-07-18 14:26 UTC
Requires
- php: ^8.1
- giggsey/libphonenumber-for-php: ^8.0
- illuminate/contracts: ^10.0|^11.0
Requires (Dev)
- larastan/larastan: ^2.0
- laravel/pint: ^1.10
- orchestra/testbench: ^8.11|^9.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
README
构建与缅甸电话号码相关的格式,并能够进行验证。
目录
安装
使用 Composer 进行安装。
composer require fawkescreatives/myanmar-phone
如果 Laravel Package Auto-Discovery 没有工作,请将以下内容添加到 config/app.php
文件中的 providers
部分:
/* * Package Service Providers... */ MyanmarPhone\MyanmarPhoneServiceProvider::class,
配置
php artisan vendor:publish --provider="MyanmarPhone\MyanmarPhoneServiceProvider"
在 config/myanmar_phone.php
中可以指定默认格式标准。
使用
- 选项 1:使用注入
use MyanmarPhone\MyanmarPhone; public function index(MyanmarPhone $service) { $phone = '09251234567'; return $service->make($phone)->getPhoneNumber(); }
- 选项 2:使用 Facade
use MyanmarPhone\Facades\MyanPhone; public function index() { $phone = '09251234567'; return MyanPhone::make($phone)->getPhoneNumber(); }
验证
例如,
Validator::make($data, [ 'phone_number' => [ 'myanmar_phone' ], ]);
函数
例如,
MyanPhone::make($phone)->format(2); // look format number in config
- format($format)
- formatE164()
- formatInternational()
- formatRFC3966(string $separator = null)
- formatNational(string $separator = null)
- operator($number = null)
- telecom($number = null)
- isTelenor($number = null)
- isOoredoo($number = null)
- isMpt($number = null)
- isMyTel($number = null)
- isMec($number = null)
- getCountryCode()
- getStrPhoneNumber()
- getPhoneNumber($leadingZero = true)
测试
可以使用以下命令运行测试:
composer test
变更日志
有关最近更改的更多信息,请参阅 变更日志。
贡献
有关详细信息,请参阅 贡献指南。
安全漏洞
有关如何报告安全漏洞,请参阅 我们的安全策略。
许可证
MIT 许可证 (MIT)。有关更多信息,请参阅 许可证文件。