Skip to content

Conversation

@henriquemoody
Copy link
Member

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)

@codecov-commenter
Copy link

codecov-commenter commented Jan 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.27%. Comparing base (0e4e571) to head (99829b7).
⚠️ Report is 1 commits behind head on main.

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.
📢 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.

@henriquemoody henriquemoody force-pushed the formatter_builder branch 3 times, most recently from 007023d to 2f0bb1b Compare January 29, 2026 22:26
@henriquemoody henriquemoody requested a review from alganet January 29, 2026 22:27
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 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 multiple Formatter instances and uses __call/__callStatic with reflection to dynamically instantiate formatter classes based on method names.
  • Introduced integration tests for FormatterBuilder, a TestingFormatter helper, 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.

@henriquemoody henriquemoody force-pushed the formatter_builder branch 2 times, most recently from c0950fa to 4096b36 Compare January 29, 2026 22:34
Copy link
Member

@alganet alganet left a 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)
@henriquemoody henriquemoody merged commit 99829b7 into Respect:main Jan 30, 2026
4 checks passed
@henriquemoody henriquemoody deleted the formatter_builder branch January 30, 2026 16:21
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