Skip to content

Containerize PhoneNumberUtil instance for Phone rule#1643

Merged
alganet merged 1 commit intoRespect:mainfrom
alganet:containerize-phonenumberutil
Jan 29, 2026
Merged

Containerize PhoneNumberUtil instance for Phone rule#1643
alganet merged 1 commit intoRespect:mainfrom
alganet:containerize-phonenumberutil

Conversation

@alganet
Copy link
Member

@alganet alganet commented Jan 29, 2026

Similar to d8e31db (commit that containerized iso code dbs), but this time for PhoneNumberUtil.

This makes the optional dependency testable.

PhoneNumberUtil doesn't have a public constructor, so a factory was declared instead.

Similar to d8e31db (commit that containerized iso code dbs), but
this time for PhoneNumberUtil.

This makes the optional dependency testable.

PhoneNumberUtil doesn't have a public constructor, so a factory
was declared instead.
@codecov
Copy link

codecov bot commented Jan 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.14%. Comparing base (d8e31db) to head (b728098).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1643      +/-   ##
============================================
+ Coverage     99.00%   99.14%   +0.13%     
  Complexity      962      962              
============================================
  Files           197      197              
  Lines          2214     2215       +1     
============================================
+ Hits           2192     2196       +4     
+ Misses           22       19       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR containerizes the PhoneNumberUtil instance for the Phone validator by registering it in the dependency injection container, making the optional dependency testable. This change aligns with the previous containerization of ISO code databases (commit d8e31db).

Changes:

  • Added PhoneNumberUtil factory registration in the container with getInstance() call
  • Changed Phone validator to check for PhoneNumberUtil availability via container instead of class_exists()
  • Updated error message to match the pattern used by other validators
  • Added comprehensive tests for both missing dependencies (PhoneNumberUtil and Countries)

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/ContainerRegistry.php Registers PhoneNumberUtil factory in the default container definitions
src/Validators/Phone.php Updates dependency checking to use container instead of class_exists(), removes unused import
tests/unit/Validators/PhoneTest.php Adds tests for missing PhoneNumberUtil and missing Countries dependencies, renames existing test for clarity

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@alganet alganet marked this pull request as ready for review January 29, 2026 20:20
@alganet alganet requested a review from henriquemoody January 29, 2026 20:20
@alganet alganet merged commit b603ef7 into Respect:main Jan 29, 2026
13 of 14 checks passed
@alganet alganet deleted the containerize-phonenumberutil branch January 29, 2026 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants