Skip to content

Releases: LacusSolutions/br-utils-php

lacus/cnpj-fmt@2.0.0

04 Apr 15:50

Choose a tag to compare

🎉 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, CnpjFormatterException and 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\ to Lacus\BrUtils\Cnpj\. Therefore update use statements and autoload expectations for CnpjFormatter, CnpjFormatterOptions, and cnpj_fmt accordingly.
  • 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() and cnpj_fmt() accept a string or a list of strings (arrays are concatenated). Passing a non-string / non–string[] value throws CnpjFormatterInputTypeError. Prior major version only accepted string, so no actual change is really needed in this topic.
  • onFail callback signature is now Closure(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 by CnpjFormatterInputLengthException (not InvalidArgumentException).
  • CnpjFormatterOptions::merge() method no longer exists. Now, to create a new version of CnpjFormatterOptions merged with other customized options, just construct a instance of the class passing the argument overrides, which accepts an array of options, with the reference instance and the attributes you want to override.
  • Options of CnpjFormatterOptions are 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 09 and AZ after normalization).
  • encode option: Optional URL encoding of the formatted CNPJ (via lacus/utils UrlUtils::encodeUriComponent), similar in spirit to encodeURIComponent.
  • HTML escaping: escape uses HtmlUtils::escape from lacus/utils instead of htmlspecialchars directly.
  • CnpjFormatter constructor: Optional first argument can be a CnpjFormatterOptions instance (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 a CnpjFormatterOptions instance or an associative array, merged with named parameters over instance defaults.
  • Explicit error model: CnpjFormatterTypeError / CnpjFormatterException hierarchies and concrete classes (CnpjFormatterInputTypeError, CnpjFormatterOptionsTypeError, CnpjFormatterOptionsHiddenRangeInvalidException, CnpjFormatterOptionsForbiddenKeyCharacterException, etc.) for typed errors and clearer handling.
  • CnpjFormatterOptions::DISALLOWED_KEY_CHARACTERS: Reserved characters for hiddenKey, dotKey, slashKey, and dashKey (internal masking pipeline).
  • CnpjFormatterOptions::getDefaultOnFail(): Shared default failure callback.

Improvements

lacus/cpf-dv@1.1.0

24 Mar 03:37

Choose a tag to compare

1.1.0

Minor Changes

  • d746c9d: (refactoring) Dropped duplicate constant declarations.
  • 2ee783e: (refactoring) Moved some input parsing logic to dedicate private method inside class CpfCheckDigits.

lacus/cnpj-dv@1.0.0

24 Mar 03:39

Choose a tag to compare

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/utils only.
  • Error handling: Specific types for type, length, and invalid input scenarios (TypeError / Exception hierarchy).

For detailed usage and API reference, see the README.

lacus/cpf-dv@1.0.0

21 Mar 14:14

Choose a tag to compare

🚀 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/utils only.
  • Error handling: Specific types for type, length, and invalid input scenarios (TypeError / Exception hierarchy).

For detailed usage and API reference, see the README.

lacus/cpf-utils@1.1.0

20 Oct 13:57

Choose a tag to compare

test(cpf-utils): wrap tests cases inside a trait

lacus/cnpj-utils@1.1.0

20 Oct 13:57

Choose a tag to compare

test(cnpj-utils): wrap tests cases inside a trait

lacus/br-utils@1.0.0

20 Oct 18:55

Choose a tag to compare

docs: fix package banner

lacus/cpf-utils@1.0.0

17 Oct 17:28

Choose a tag to compare

docs(cpf-utils): create README

lacus/cnpj-utils@1.0.0

17 Oct 18:48

Choose a tag to compare

docs(cnpj-utils): create README

lacus/cpf-gen@1.0.1

13 Oct 11:03

Choose a tag to compare

chore: merge commit 'f8dc82392757ac10ff8cb756ca6c730561ef4753'