Containerize PhoneNumberUtil instance for Phone rule#1643
Containerize PhoneNumberUtil instance for Phone rule#1643alganet merged 1 commit intoRespect:mainfrom
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
PhoneNumberUtilfactory registration in the container withgetInstance()call - Changed Phone validator to check for
PhoneNumberUtilavailability via container instead ofclass_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.
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.