Skip to content

Conversation

@henriquemoody
Copy link
Member

The class was called Factory because we used to use it to create rules and exceptions. Since we don’t have more exceptions per rule, the name RuleFactory makes more sense, as it accurately describes its purpose.

I’ve turned that class into an interface, and copied the implementation to a new class, NamespacedRuleFactory, which describes more of what that specific implementation does.

@codecov
Copy link

codecov bot commented Dec 30, 2025

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #1582   +/-   ##
=========================================
  Coverage     97.54%   97.54%           
  Complexity      999      999           
=========================================
  Files           211      211           
  Lines          2278     2280    +2     
=========================================
+ Hits           2222     2224    +2     
  Misses           56       56           

☔ 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 refactors the Factory class into a more clearly defined architecture by introducing a RuleFactory interface and implementing it with a NamespacedRuleFactory class. The refactoring improves code clarity by making the factory's purpose explicit and separating the interface from its implementation.

  • Introduced RuleFactory interface with a create() method to replace the previous rule() method
  • Renamed Factory class to NamespacedRuleFactory to better describe its namespace-based rule resolution behavior
  • Updated all references throughout the codebase to use the new interface and implementation

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
library/RuleFactory.php Defines the new interface for rule creation with a standardized create() method signature
library/NamespacedRuleFactory.php Implements RuleFactory interface as a readonly class with namespace-based rule resolution logic
library/Validator.php Updates type hint from Factory to RuleFactory interface and method call from rule() to create()
library/ContainerRegistry.php Updates dependency injection configuration to bind RuleFactory interface to NamespacedRuleFactory implementation
tests/unit/NamespacedRuleFactoryTest.php Renames test class and updates all test cases to use new class and method names

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

The class was called `Factory` because we used to use it to create rules
and exceptions. Since we don’t have more exceptions per rule, the name
`RuleFactory` makes more sense, as it accurately describes its purpose.

I’ve turned that class into an interface, and copied the implementation
to a new class, `NamespacedRuleFactory`, which describes more of what
that specific implementation does.
@henriquemoody henriquemoody merged commit bf5f6c0 into Respect:main Dec 30, 2025
5 checks passed
@henriquemoody henriquemoody deleted the core/factory branch December 30, 2025 10:46
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.

1 participant