lumenpink/typesbr

巴西文件和数字的常用类型(目前只有CPF)

0.0.3 2024-01-15 14:54 UTC

This package is auto-updated.

Last update: 2024-09-17 17:11:00 UTC


README

TypesBR

Lumenpink/Typesbr

巴西文件和数字的常用类型(目前只有CPF)

安装

使用composer安装它

composer require lumenpink/typesbr

使用

use Lumenpink/Typesbr/Cpf

# Create new CPF
$cpf = new Cpf('000.000.001-91')  // it accepts with or without mask or leading zeroes
                                  // it throwns an InvalidArgumentException if invalid

# Return only digits
$cpf->digits(); // returns 00000000191

# Or the formatted (masked) version
$Cpf->formated(); // returns 000.000.001-91

# Return the type of document
$Cpf->type(); // returns 'cpf'

# Use it as primitive type on a function
function foo (Cpf $cpf) {
    do_something_with_this_shining_new_and_valid_cpf($cpf)
}

测试

我们喜欢Nuno Maduro的PEST Suite

要运行测试,只需输入

vendor/bin/pest

贡献

欢迎提交pull请求。对于重大更改,请先打开一个问题来讨论您想要更改的内容。

请确保适当更新测试。

许可证

MIT