1.10.0 - Custom Reporters & Architecture Improvements
What's Changed
✨ New Features
- Custom Reporters Support by @floriankraemer in #61
- Added comprehensive extensibility framework for creating custom reporters
- Support for both cognitive metrics and churn metrics reporters
- New
ReporterRegistryclass for managing and loading custom reporters - Configuration support via
config.ymlfor registering custom reporters - Automatic detection of constructor requirements (with or without
CognitiveConfig) - Support for both autoloaded classes and file-based reporters
- Comprehensive documentation in
docs/Creating-Custom-Reporters.md
🏗️ Architecture Improvements
-
Terminology Refactoring: Exporters → Reports by @floriankraemer in #61
- Renamed all "Exporter" classes to "Report" for better semantic clarity
- Migrated
Business/Churn/Exporter/→Business/Churn/Report/ - Migrated
Business/Cognitive/Exporter/→Business/Cognitive/Report/ - Updated interface names:
DataExporterInterface→ReportGeneratorInterface - Improved naming consistency across the codebase
-
Enhanced Factory Pattern Implementation by @floriankraemer in #61
- Introduced
ChurnReportFactoryandChurnReportFactoryInterface - Introduced
CognitiveReportFactoryandCognitiveReportFactoryInterface - Removed legacy
ChurnExporterFactoryandCognitiveExporterFactory - Better separation of concerns with dedicated factory interfaces
- Support for dynamic reporter registration and instantiation
- Introduced
-
Specification Pattern for Command Validation by @floriankraemer in #61
- Implemented comprehensive validation using Specification Pattern
- New command context classes:
ChurnCommandContext,CognitiveMetricsCommandContext - Composite specifications for complex validation logic:
CompositeChurnSpecificationCompositeCognitiveMetricsValidationSpecification
- Individual specification classes for focused validation:
CoverageFileExistsCoverageFormatSupportedCoverageFormatExclusivityCustomExporterValidationSortFieldValidSortOrderValidReportOptionsComplete
- Validation specification factories for both commands
- Improved error messages and validation feedback
-
Command Handler Refactoring by @floriankraemer in #61
- Introduced dedicated handler classes for better separation of concerns
- New handlers for cognitive analysis:
BaselineHandler- Handles baseline comparison logicConfigurationLoadHandler- Manages configuration loadingCoverageLoadHandler- Handles coverage data loadingSortingHandler- Manages metrics sorting
- Enhanced
ChurnReportHandlerandCognitiveMetricsReportHandler - Simplified command classes by delegating to specialized handlers
-
Enhanced Data Models by @floriankraemer in #61
- Introduced
ChurnMetricsclass for better data encapsulation - Introduced
ChurnMetricsCollectionfor collection management - New
OperationResultclass for standardized command results - Improved type safety and data structure consistency
- Introduced
-
Code Organization Improvements by @floriankraemer in #61
- Moved
DirectoryScannertoBusiness/Utility/namespace - Moved
CoverageDataDetectortoBusiness/Utility/namespace - Better logical grouping of utility classes
- Improved namespace structure
- Moved
🧪 Testing & Quality Assurance
- Comprehensive Test Coverage by @floriankraemer in #61
- Added 1,000+ lines of new test coverage
- New test fixtures for custom reporters:
ConfigAwareChurnTextReporterConfigAwareTextReporterCustomChurnTextReporterCustomTextReporter
- Comprehensive tests for specification pattern:
ChurnSpecificationPatternTestCognitiveMetricsSpecificationPatternTest
- Factory pattern tests:
ChurnReporterFactoryCustomTestCognitiveReporterFactoryCustomTest
- Configuration tests:
CustomExportersConfigTest
- Command tests:
- Enhanced
ChurnCommandTest - Enhanced
CognitiveMetricsCommandTest
- Enhanced
- Reporter registry tests:
ExporterRegistryTest
- Custom reporter integration tests:
MetricsFacadeCustomExportersTest
📚 Documentation
- Creating Custom Reporters Guide by @floriankraemer in #61
- Comprehensive 287-line documentation for custom reporter development
- Detailed examples for both cognitive and churn reporters
- Configuration guidelines and best practices
- Constructor pattern explanations
- Troubleshooting section
- Built-in reporter reference
🔧 Configuration Enhancements
- Custom Reporters Configuration by @floriankraemer in #61
- Added
customReporterssection toconfig.yml - Support for cognitive and churn reporter registration
- Flexible configuration with optional file paths
- Example configuration in default config file
- Added
Changes
- Support for custom Reporters by @floriankraemer in #61
Full Changelog: 1.9.0...1.10.0
Key Highlights
- Major Extensibility Enhancement: The custom reporters feature allows developers to create their own output formats without modifying the core codebase
- Improved Architecture: Comprehensive refactoring with better separation of concerns, specification pattern validation, and enhanced factory patterns
- Better Code Organization: Terminology improvements (Exporters → Reports) and logical namespace restructuring
- Robust Testing: Over 1,000 lines of new test coverage ensuring reliability of the new features
- Developer-Friendly: Comprehensive documentation and examples make it easy to create custom reporters
Migration Guide
If you're upgrading from 1.9.0, please note:
- No Breaking Changes: All existing functionality remains compatible
- Optional Feature: Custom reporters are entirely optional - existing workflows continue to work unchanged
- Configuration: If you want to use custom reporters, add the
customReporterssection to yourconfig.yml(see documentation) - Internal API Changes: If you've extended the codebase, note that "Exporter" classes have been renamed to "Report" classes
Example Usage
Using Built-in Reports (Unchanged)
# Cognitive metrics
bin/phpcca analyse ./src --format=json --output=report.json
# Churn metrics
bin/phpcca churn ./src --format=html --output=churn.htmlUsing Custom Reporters (New)
# config.yml
cognitive:
customReporters:
cognitive:
pdf:
class: 'My\Custom\PdfReporter'
file: '/path/to/PdfReporter.php'bin/phpcca analyse ./src --format=pdf --output=report.pdfSee docs/Creating-Custom-Reporters.md for complete documentation.