[v3][cnpj-dv] Create cnpj-dv package for CNPJ check digit calculation supporting alphanumeric format#37
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a new PHP package Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes Possibly related issues
Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/cnpj-dv/README.md`:
- Around line 94-96: Update the emphasis style in the README entries for
CnpjCheckDigitsTypeError and CnpjCheckDigitsException by replacing the
underscore-wrapped `_abstract_` with asterisk-wrapped `*abstract*` so it matches
the rest of the document’s use of asterisks; locate the lines referencing
CnpjCheckDigitsTypeError, CnpjCheckDigitsInputTypeError, and
CnpjCheckDigitsException and change `_abstract_` to `*abstract*` for
consistency.
In `@packages/cnpj-dv/README.pt.md`:
- Around line 66-70: Replace the underscore-based emphasis with asterisk-based
emphasis for consistency: update the two occurrences of `_abstract_` to
`*abstract*` in the README entries for CnpjCheckDigitsTypeError and
CnpjCheckDigitsException so they match the document's existing asterisk emphasis
style.
In `@packages/cnpj-dv/src/CnpjCheckDigits.php`:
- Around line 175-178: The error currently throws CnpjCheckDigitsInputTypeError
with the entire $cnpjArray inside the foreach, which hides which element failed;
update the throw so it reports the offending member (use $item and ideally its
index) instead of $cnpjArray — locate the foreach over $cnpjArray and change the
thrown CnpjCheckDigitsInputTypeError payload/arguments to include the invalid
$item (and/or its key) and the expected type 'string or string[]' so the
exception shows the exact bad value.
- Around line 251-256: The method validateNonRepeatedDigits uses the bare
constant CNPJ_MIN_LENGTH which pulls a namespace-level constant instead of the
class constant; update the reference in validateNonRepeatedDigits to use
self::CNPJ_MIN_LENGTH (match other usages in the class) so the method relies on
the class-defined constant and avoids the hidden cross-file dependency.
In `@packages/cnpj-dv/src/Exceptions/CnpjCheckDigitsInputLengthException.php`:
- Line 36: Update the exception message in CnpjCheckDigitsInputLengthException
(the parent::__construct call) to use "characters" instead of "digits" so it
reflects alphanumeric CNPJ support; locate the constructor that currently builds
the message "CNPJ input {$fmtActual} does not contain {$minExpectedLength} to
{$maxExpectedLength} digits. Got {$fmtEvaluated}." and replace "digits" with
"characters" while preserving the formatted placeholders and punctuation.
In `@packages/cnpj-dv/tests/Specs/Exceptions.spec.php`:
- Around line 196-210: The spec and exception message hard-code "digits" which
is now incorrect for alphanumeric CNPJs; update the message wording in the
CnpjCheckDigitsInputLengthException (and its test in Specs/Exceptions.spec.php)
to use "characters" or "alphanumeric characters" instead of "digits" — locate
the CnpjCheckDigitsInputLengthException constructor/ getMessage implementation
and change the phrase that builds the message, then adjust the test's
$actualMessage string to match the new wording so
expect($exception->getMessage())->toBe($actualMessage) passes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: bd476309-3096-4502-b49a-92755ba8193a
📒 Files selected for processing (21)
packages/cnpj-dv/CHANGELOG.mdpackages/cnpj-dv/LICENSEpackages/cnpj-dv/README.mdpackages/cnpj-dv/README.pt.mdpackages/cnpj-dv/composer.jsonpackages/cnpj-dv/phpunit.xmlpackages/cnpj-dv/src/CnpjCheckDigits.phppackages/cnpj-dv/src/Exceptions/CnpjCheckDigitsException.phppackages/cnpj-dv/src/Exceptions/CnpjCheckDigitsInputInvalidException.phppackages/cnpj-dv/src/Exceptions/CnpjCheckDigitsInputLengthException.phppackages/cnpj-dv/src/Exceptions/CnpjCheckDigitsInputTypeError.phppackages/cnpj-dv/src/Exceptions/CnpjCheckDigitsTypeError.phppackages/cnpj-dv/src/cnpj-dv.phppackages/cnpj-dv/tests/Mocks/CnpjCheckDigitsWithCalculateSpy.phppackages/cnpj-dv/tests/Pest.phppackages/cnpj-dv/tests/Specs/CnpjCheckDigits.spec.phppackages/cnpj-dv/tests/Specs/Exceptions.spec.phppackages/cnpj-dv/tests/Specs/Package.spec.phppackages/cpf-dv/src/CpfCheckDigits.phppackages/cpf-dv/src/cpf-dv.phppackages/cpf-dv/tests/Specs/Package.spec.php
💤 Files with no reviewable changes (1)
- packages/cpf-dv/src/cpf-dv.php
Summary by CodeRabbit
New Features
Documentation
Tests
Chores