joulgs/php-utils
最新稳定版本:1.2.0
Composer 安装命令:
composer require joulgs/php-utils
包简介
PHP validation and formatting tools
README 文档
README
Installation
php-utils is available via composer. To install it, simply run the following command:
composer require joulgs/php-utils
Available Classes
FiscalDocuments
Allows you to validate a tax number and obtain its type (CPF, CNPJ or NIF).
Methods
| Method | Description |
|---|---|
| getType | Returns the type of the tax number (CPF, CNPJ or NIS) |
| isValid | Returns true if the tax number is valid |
| isInvalid | Returns true if the tax number is invalid |
| getMasked | Returns the tax number with a mask |
Example
<?php use JGS\Utils\FiscalDocuments; $doc_number = new FiscalDocuments('12345678901'); echo $doc_number->getType(); // CPF if($doc_number->isValid()) { echo "Valid Doc Number"; } if($doc_number->isInvalid()) { echo "Invalid Doc Number"; } echo $doc_number->getMasked(); // 123.456.789-01
Tools
A set of tools to help you with your daily tasks.
Methods
| Method | Description |
|---|---|
| formatPhone | Formats a phone number |
| mask | Applies a mask to a string |
*Other methods will be added soon.
Example
<?php use JGS\Utils\Tools; $phone = Tools::formatPhone('1234567890'); echo $phone; // (12) 3456-7890 $phone = Tools::formatPhone('12345678901'); echo $phone; // (12) 34567-8901 $phone = Tools::formatPhone('551234567890'); echo $phone; // +55 (12) 3456-7890 $phone = Tools::formatPhone('5512345678901'); echo $phone; // +55 (12) 34567-8901 $masked = Tools::mask('12345678901', '###.###.###-##'); echo $masked; // 123.456.789-01 $masked = Tools::mask('1234567890', '##-##-##-##'); echo $masked; // 12-34-56-78
统计信息
- 总下载量: 28
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-06-20