springy-framework/brazilian-numbers
Composer 安装命令:
composer require springy-framework/brazilian-numbers
包简介
PHP class for validate and check brazilian document and numbers
README 文档
README
This package can validate documents like CPF, CNPJ, CNH, NIS and "inscrição estadual".
It can take the strings with the numbers of documents of people and companies from Brazil and perform format and check digit verifications to determine if they can be valid.
Requirements
- PHP 8.1+
Instalation
To get the latest stable version of this component use:
"require": { "springy-framework/brazilian-numbers": "*" }
in your composer.json file.
Usage
I suppose that the following example is all you need:
<?php require 'vendor/autoload.php'; // If you're using Composer (recommended) // The following numbers can also be used without a mask. $cpf = '899.678.736-12'; $cnpj = '76.871.442/0001-75'; $cnh = '21059294129'; $nis = '640.58791.38-4'; $ierj = '18.251.03-5'; if (Springy\Utils\BrazilianNumbers\Cpf::isValid($cpf)) { echo "CPF valid!\n"; } else { echo "CPF invalid!\n"; } if (Springy\Utils\BrazilianNumbers\Cnpj::isValid($cnpj)) { echo "CNPJ valid!\n"; } else { echo "CNPJ invalid!\n"; } if (Springy\Utils\BrazilianNumbers\Cnh::isValid($cnh)) { echo "CNH valid!\n"; } else { echo "CNH invalid!\n"; } if (Springy\Utils\BrazilianNumbers\Nis::isValid($nis)) { echo "NIS valid!\n"; } else { echo "NIS invalid!\n"; } if (Springy\Utils\BrazilianNumbers\InscricaoEstadual::isValid($ierj)) { echo "IE valid!\n"; } else { echo "IE invalid!\n"; } echo Springy\Utils\BrazilianNumbers\Cpf::mask('89967873612'); echo Springy\Utils\BrazilianNumbers\Cnpj::mask('76871442000175'); echo Springy\Utils\BrazilianNumbers\Nis::mask('64058791384'); echo Springy\Utils\BrazilianNumbers\InscricaoEstadual::mask('18251035'); echo Springy\Utils\BrazilianNumbers\Cpf::unmask($cpf); echo Springy\Utils\BrazilianNumbers\Cnpj::unmask($cnpj); echo Springy\Utils\BrazilianNumbers\Nis::unmask($nis); echo Springy\Utils\BrazilianNumbers\InscricaoEstadual::unmask($ierj);
Contributing
Please read our contributing document and thank you for doing that.
Code of Conduct
In order to ensure that our community is welcoming to all, please review and abide by the code of conduct.
License
This project is licensed under The MIT License (MIT).
统计信息
- 总下载量: 529
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-11-30