Update library for latest PHP version#12
Merged
Conversation
Breaking Changes: - Minimum PHP version is now 8.1 - Updated PHPUnit to version 10/11 New Features: - Added validar() method for auto-detecting document type (cedula/RUC) - Added getTipoDocumento() method to get the detected document type - Added support for province code 30 (Ecuadorians abroad/foreign residents) - For code 30, third digit validation is skipped (addresses PR #6) - Added PHP 8.x type hints, return types, and match expressions - Added document type constants (TIPO_CEDULA, TIPO_RUC_NATURAL, etc.) Bug Fixes: - Issue #3: Documented that RUC 0962893970001 is mathematically invalid (check digit is 7 but should be 1). Added test to verify correct behavior. - Issue #7: Verified switch case has proper breaks in validarTercerDigito() Tests: - Added 79 comprehensive tests (up from ~38) - Added tests for province code 30 (foreign residents) - Added tests for universal validation method - Added edge case tests for all document types Documentation: - Translated README to English - Added complete province code list - Added validation limitations section - Added changelog for v2.0.0
Translate all Spanish error messages to English for consistency: - Value cannot be empty - Value can only contain digits - Value must have X characters - Province code (first two digits) must be between 01-24 or 30 - Third digit must be between 0 and 5 for cedula and natural person RUC - Third digit must be 9 for private companies - Third digit must be 6 for public companies - Establishment code cannot be 0 - Check digit validation failed - Invalid identification type Updated all 5 test files to match the new English messages. All 79 tests pass.
Breaking Changes: - Constants renamed: TIPO_* → TYPE_* - Method names now in English (legacy Spanish methods deprecated) New Method Names: - validate() - auto-detect and validate any document - validateCedula() - validate Cedula - validateNaturalPersonRuc() - validate Natural Person RUC - validatePrivateCompanyRuc() - validate Private Company RUC - validatePublicCompanyRuc() - validate Public Company RUC - getDocumentType() - get detected document type Code Improvements: - Class marked as final - Private internal validation methods (perform*) - Constants for coefficients and magic numbers - Match expressions for cleaner conditionals - Removed code duplication - All variable names in English - Comprehensive PHPDoc comments Test Improvements: - All test files renamed to English - Test method names in English - 77 tests with 162 assertions Legacy Support: - All Spanish method names still work (@deprecated) - Backwards compatible for existing users
Breaking changes for v2.0.0: - Removed validar() - use validate() - Removed validarCedula() - use validateCedula() - Removed validarRucPersonaNatural() - use validateNaturalPersonRuc() - Removed validarRucSociedadPrivada() - use validatePrivateCompanyRuc() - Removed validarRucSociedadPublica() - use validatePublicCompanyRuc() - Removed getTipoDocumento() - use getDocumentType() This is a clean v2.0 release with no backwards compatibility.
Co-authored-by: StyleCI Bot <bot@styleci.io>
- Run tests on PHP 8.1, 8.2, 8.3, 8.4 - Trigger on push and PR to main/master
- Add static validation methods for quick checks without instantiation: - isValid() for any document type - isValidCedula(), isValidNaturalPersonRuc(), etc. - Add extractCedulaFromRuc() to extract cedula from natural person RUC - Update README with comprehensive v2.0.0 documentation - Add 16 new tests (total: 93 tests)
Co-authored-by: StyleCI Bot <bot@styleci.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request modernizes the Ecuadorian ID and RUC validator library by updating its documentation, package configuration, and test suite to improve usability, maintainability, and compliance with current PHP standards. The most significant changes include raising the minimum PHP version requirement, updating documentation for clarity and English language usage, adding comprehensive tests for cedula and RUC validation (including foreign resident support), and aligning the package and test configurations with best practices.
Documentation and API Modernization:
readme.mdhas been fully rewritten in English, providing clearer usage instructions, detailed API documentation, and comprehensive explanations of document structure, validation logic, and limitations. The documentation now highlights the new English method names, constants, and the universalvalidate()method, and includes explicit support for province code 30 (foreign residents).Composer and Package Configuration Updates:
composer.jsonnow requires PHP 8.1 or higher, updates the PHPUnit requirement to ^10.0|^11.0, adds relevant keywords, updates author information, and enables stable package preference and sorted dependencies. [1] [2] [3]Test Suite Improvements:
phpunit.xml) is updated for compatibility with PHPUnit 10+, including schema validation, new options for execution order and reporting, and a modernized source inclusion structure.tests/CedulaValidationTest.phpcovers all edge cases for cedula validation, including invalid input, valid cases across provinces, and special handling for province code 30 (foreign residents).tests/NaturalPersonRucValidationTest.phpprovides similar coverage for natural person RUC validation, including establishment code checks and foreign resident support.These changes collectively ensure the library is robust, well-documented, and ready for modern PHP environments.