Releases: LacusSolutions/br-utils-php
Releases · LacusSolutions/br-utils-php
lacus/cnpj-fmt@2.0.0
🎉 v2 at a glance 🎊
- 🆕 Alphanumeric CNPJ — Full support for the new 14-character alphanumeric CNPJ (digits and letters); input is sanitized and uppercased before formatting.
- 🛡️ Structured errors — Typed exceptions (
CnpjFormatterTypeError,CnpjFormatterExceptionand their subclasses variants) for clearer error handling.
BREAKING CHANGES
- Letters no longer stripped from the input. With the new alphanumeric CNPJ format, letters are kept in the input sanitization and validated on the length of processed data.
- Namespace: In the process of normalizing the namespaces of BR Utils resources, the package's public API moved from
Lacus\CnpjFmt\toLacus\BrUtils\Cnpj\. Therefore updateusestatements and autoload expectations forCnpjFormatter,CnpjFormatterOptions, andcnpj_fmtaccordingly. - Drop support to PHP v8.1: Minimum version for the package is now PHP 8.2 (
^8.2). It may even run forcedly in earlier versions, but it's not recommended to keep running stale versions of PHP in production. - Input type:
CnpjFormatter::format()andcnpj_fmt()accept a string or a list of strings (arrays are concatenated). Passing a non-string / non–string[]value throwsCnpjFormatterInputTypeError. Prior major version only acceptedstring, so no actual change is really needed in this topic. onFailcallback signature is nowClosure(mixed $value, CnpjFormatterException $exception): string. The default implementation returns an empty string on failure; v1 defaulted to returning the original input string for invalid length. Length failures are now represented byCnpjFormatterInputLengthException(notInvalidArgumentException).CnpjFormatterOptions::merge()method no longer exists. Now, to create a new version ofCnpjFormatterOptionsmerged with other customized options, just construct a instance of the class passing the argumentoverrides, which accepts an array of options, with the reference instance and the attributes you want to override.- Options of
CnpjFormatterOptionsare now accessible as properties, instead of getters and setters. - Migrated tests from PhpUnit to Pest.
New features
- Alphanumeric CNPJ: Full support for the new alphanumeric CNPJ format (14 characters from
0–9andA–Zafter normalization). encodeoption: Optional URL encoding of the formatted CNPJ (vialacus/utilsUrlUtils::encodeUriComponent), similar in spirit toencodeURIComponent.- HTML escaping:
escapeusesHtmlUtils::escapefromlacus/utilsinstead ofhtmlspecialcharsdirectly. CnpjFormatterconstructor: Optional first argument can be aCnpjFormatterOptionsinstance (shared by reference), or options can be passed as named parameters; v1 only accepted flat option parameters in a fixed order.format()per-call options: Second argument may be aCnpjFormatterOptionsinstance or an associative array, merged with named parameters over instance defaults.- Explicit error model:
CnpjFormatterTypeError/CnpjFormatterExceptionhierarchies and concrete classes (CnpjFormatterInputTypeError,CnpjFormatterOptionsTypeError,CnpjFormatterOptionsHiddenRangeInvalidException,CnpjFormatterOptionsForbiddenKeyCharacterException, etc.) for typed errors and clearer handling. CnpjFormatterOptions::DISALLOWED_KEY_CHARACTERS: Reserved characters forhiddenKey,dotKey,slashKey, anddashKey(internal masking pipeline).CnpjFormatterOptions::getDefaultOnFail(): Shared default failure callback.
Improvements
- New PT-BR documentation: New README in Brazilian Portuguese.
lacus/cpf-dv@1.1.0
lacus/cnpj-dv@1.0.0
1.0.0
🚀 Stable Version Released!
Utility class to calculate check digits on CNPJ (Cadastro Nacional da Pessoa Jurídica). Main features:
- Flexible input: Accepts string or array of strings (formatted or raw).
- Format agnostic: Automatically strips non-numeric characters from input.
- Lazy evaluation & caching: Check digits are calculated only when accessed for the first time.
- Minimal dependencies:
lacus/utilsonly. - Error handling: Specific types for type, length, and invalid input scenarios (
TypeError/Exceptionhierarchy).
For detailed usage and API reference, see the README.
lacus/cpf-dv@1.0.0
🚀 Stable Version Released!
Utility class to calculate check digits on CPF (Brazilian Individual's Taxpayer ID). Main features:
- Flexible input: Accepts string or array of strings (formatted or raw).
- Format agnostic: Automatically strips non-numeric characters from input.
- Lazy evaluation & caching: Check digits are calculated only when accessed for the first time.
- Minimal dependencies:
lacus/utilsonly. - Error handling: Specific types for type, length, and invalid input scenarios (
TypeError/Exceptionhierarchy).
For detailed usage and API reference, see the README.
lacus/cpf-utils@1.1.0
test(cpf-utils): wrap tests cases inside a trait
lacus/cnpj-utils@1.1.0
test(cnpj-utils): wrap tests cases inside a trait
lacus/br-utils@1.0.0
docs: fix package banner
lacus/cpf-utils@1.0.0
docs(cpf-utils): create README
lacus/cnpj-utils@1.0.0
docs(cnpj-utils): create README
lacus/cpf-gen@1.0.1
chore: merge commit 'f8dc82392757ac10ff8cb756ca6c730561ef4753'