Repository navigation
Refactor large classes and remove PHPMD exceptions - #44
Merged
Merged
Conversation
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Reduces public API from 27 to 11 methods by exposing ExecutionHistory, ExecutionStatus, and LockState directly. Keeps mutation wrappers for ExecutionHistory (immutable) while allowing direct access to composed objects for reading. Breaking changes: - Remove delegation methods (getActionExecutions, getGateEvaluations, etc.) - Rename mutation methods (addActionResult → recordActionExecution, etc.) - Status methods now accessed via executionStatus() (isPaused → executionStatus()->isPaused()) - Lock state accessed via lockState() instead of getLockState() PHPMD improvements: - TransitionContext: TooManyPublicMethods reduced from 27 to 11 methods (goal: 10) - TransitionContext: CouplingBetweenObjects reduced from 19 to 16 dependencies All 396 tests passing with 100% coverage maintained. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Moves serialization responsibility entirely to TransitionContextSerializer to reduce public method count from 11 to 9 (below threshold of 10). Breaking changes: - Remove serialize() method - use (new TransitionContextSerializer())->serialize($context) - Remove unserialize() static method - use (new TransitionContextSerializer())->unserialize(...) - Users must call TransitionContextSerializer directly PHPMD improvements: - TransitionContext: TooManyPublicMethods RESOLVED (9 < 10) ✅ - TransitionContext: CouplingBetweenObjects RESOLVED (no longer in violations) ✅ All 396 tests passing with 100% coverage maintained. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Successfully refactored large classes by extracting focused responsibilities and removing most PHPMD custom thresholds.
Changes Made
Updated phpmd.xml.dist
TooManyPublicMethodsthreshold (now using default: 10)ExcessiveClassComplexitythreshold (now using default: 50)CouplingBetweenObjectsthreshold (now using default: 13)LongVariableto 25 (reasonable vs default 17)Extracted LockManager from StateWorker
src/Locking/LockManager.phpclass (264 lines, 7 methods)Extracted TransitionContextSerializer from TransitionContext
src/TransitionContextSerializer.phpclass (332 lines)Restored Event.php suppression
Metrics Improvements
Before:
After:
Violations Resolved
✅ ExcessiveClassComplexity in StateWorker (was 63 > 50)
✅ ExcessiveClassComplexity in TransitionContext (was 56 > 50)
✅ Significant coupling reduction in both classes
Remaining Violations (Acceptable)
The remaining PHPMD violations are minor and justified:
Benefits
Closes #26
Test Plan
🤖 Generated with Claude Code