-
Notifications
You must be signed in to change notification settings - Fork 1
Add FormatterBuilder for fluent formatter chaining #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3 +/- ##
============================================
+ Coverage 99.22% 99.27% +0.04%
- Complexity 126 132 +6
============================================
Files 11 12 +1
Lines 259 276 +17
============================================
+ Hits 257 274 +17
Misses 2 2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
007023d to
2f0bb1b
Compare
2f0bb1b to
ba22dc2
Compare
There was a problem hiding this 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 pull request introduces a FormatterBuilder to support fluent chaining of existing formatters (MaskFormatter, PatternFormatter, PlaceholderFormatter), along with integration tests and documentation updates. It also adds mixin interfaces to improve the static analysis story around fluent builder usage.
Changes:
- Added
FormatterBuilder, which composes multipleFormatterinstances and uses__call/__callStaticwith reflection to dynamically instantiate formatter classes based on method names. - Introduced integration tests for
FormatterBuilder, aTestingFormatterhelper, and a dedicated PHPUnit testsuite for integration tests. - Updated the README with a usage example demonstrating chained formatter operations via
FormatterBuilder.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/FormatterBuilder.php | Implements the fluent builder that chains Formatter instances, including dynamic formatter resolution, error handling, and static factory support. |
| src/Mixin/Chain.php | Defines a Chain mixin interface extending Formatter with static methods returning FormatterBuilder to describe the fluent chaining API. |
| src/Mixin/Builder.php | Defines a Builder mixin interface describing static factory-style builder entry points (mask, pattern, placeholder) for static analysis. |
| tests/Integration/FormatterBuilderTest.php | Adds integration tests that verify single and multiple formatter chains, static factory calls, and key exception paths for FormatterBuilder. |
| tests/Helper/TestingFormatter.php | Provides a simple Formatter implementation for tests that captures input and returns a deterministic or generated output. |
| phpunit.xml.dist | Registers a new integration testsuite to run the integration tests under tests/Integration/. |
| README.md | Documents the new fluent builder usage pattern with a concrete example combining mask and pattern formatters. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c0950fa to
4096b36
Compare
alganet
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General questions for now. I want to understand better some decisions. Is the defensiveness in the __call preparation for something later?
The FormatterBuilder provides a fluent API to chain multiple formatters together, making it simpler to compose complex string transformations. Instead of manually instantiating and nesting formatters, developers can now use a readable builder pattern. Assisted-by: Claude Code (Claude Opus 4.5)
4096b36 to
99829b7
Compare
The FormatterBuilder provides a fluent API to chain multiple formatters together, making it simpler to compose complex string transformations. Instead of manually instantiating and nesting formatters, developers can now use a readable builder pattern.
Assisted-by: Claude Code (Claude Opus 4.5)