-
Notifications
You must be signed in to change notification settings - Fork 31
Rename classes/functions #369
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
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThis pull request refactors CSV import services by renaming classes and methods for semantic clarity. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
config/services/mappers.yml(1 hunks)src/Domain/Subscription/Service/ArrayToDtoMapper.php(1 hunks)src/Domain/Subscription/Service/CsvToDtoImporter.php(2 hunks)src/Domain/Subscription/Service/SubscriberCsvImporter.php(7 hunks)tests/Unit/Domain/Subscription/Service/SubscriberCsvImporterTest.php(10 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/Domain/**
⚙️ CodeRabbit configuration file
src/Domain/**: You are reviewing PHP domain-layer code. Enforce strict domain purity:
- ❌ Do not allow infrastructure persistence side effects here.
- Flag ANY usage of Doctrine persistence APIs, especially:
- $entityManager->flush(...), $this->entityManager->flush(...)
- $em->persist(...), $em->remove(...)
- direct transaction control ($em->beginTransaction(), commit(), rollback())
- If found, request moving these calls to application-layer Command handlers or background Jobs.
- Also flag repositories in Domain that invoke flush/transactional logic; Domain repositories should be abstractions without side effects.
- Encourage domain events/outbox or return-values to signal write-intent, leaving orchestration to Commands/Jobs.
Files:
src/Domain/Subscription/Service/ArrayToDtoMapper.phpsrc/Domain/Subscription/Service/CsvToDtoImporter.phpsrc/Domain/Subscription/Service/SubscriberCsvImporter.php
🧬 Code graph analysis (3)
src/Domain/Subscription/Service/CsvToDtoImporter.php (2)
src/Domain/Subscription/Service/SubscriberCsvImporter.php (1)
__construct(47-67)src/Domain/Subscription/Service/ArrayToDtoMapper.php (1)
ArrayToDtoMapper(9-52)
src/Domain/Subscription/Service/SubscriberCsvImporter.php (1)
src/Domain/Subscription/Service/CsvToDtoImporter.php (2)
CsvToDtoImporter(14-62)parseAndValidate(28-61)
tests/Unit/Domain/Subscription/Service/SubscriberCsvImporterTest.php (1)
src/Domain/Subscription/Service/CsvToDtoImporter.php (1)
CsvToDtoImporter(14-62)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: phpList on PHP 8.1 [Build, Test]
- GitHub Check: phpList on PHP 8.1 [Build, Test]
🔇 Additional comments (11)
src/Domain/Subscription/Service/ArrayToDtoMapper.php (1)
9-9: LGTM! Clean semantic rename.The rename from
CsvRowToDtoMappertoArrayToDtoMapperbetter reflects that this mapper works with generic arrays rather than being tightly coupled to CSV-specific concepts. The implementation remains unchanged and continues to handle the mapping logic correctly.config/services/mappers.yml (1)
7-13: LGTM! Service configuration properly updated.The service definitions have been correctly updated to reference the renamed classes while preserving all autowiring and autoconfiguration settings.
src/Domain/Subscription/Service/CsvToDtoImporter.php (3)
14-14: LGTM! Better semantic clarity.The rename to
CsvToDtoImportermore explicitly conveys that this class transforms CSV data into DTOs, making the codebase more self-documenting.
17-17: LGTM! Dependency updated consistently.The constructor parameter type correctly reflects the
ArrayToDtoMapperrename, maintaining consistency across the refactoring.
28-28: LGTM! Method name is more descriptive.Renaming
import()toparseAndValidate()better describes what this method actually does—it parses CSV data and validates DTOs without performing any persistence. This improves code readability and sets clearer expectations for callers.tests/Unit/Domain/Subscription/Service/SubscriberCsvImporterTest.php (2)
15-15: LGTM! Tests properly updated for API changes.The test imports, mock declarations, and constructor invocations have been correctly updated to use
CsvToDtoImporterinstead ofCsvImporter, maintaining test coverage for the renamed classes.Also applies to: 32-32, 42-42, 51-51
111-111: LGTM! Method expectations consistently updated.All mock method expectations have been updated from
importtoparseAndValidate, ensuring the tests align with the new public API surface.Also applies to: 176-176, 247-247, 312-312, 372-372, 432-432
src/Domain/Subscription/Service/SubscriberCsvImporter.php (4)
41-41: LGTM! Dependency properly updated.The property, constructor parameter, and assignment have been correctly updated from
CsvImportertoCsvToDtoImporter, maintaining consistency with the class rename.Also applies to: 52-52, 62-62
84-84: LGTM! Stats array extended for invalid email tracking.The addition of
invalid_emailto the stats array initialization properly supports the new tracking requirement.
96-96: LGTM! Method call updated consistently.The call correctly uses the renamed
parseAndValidate()method, maintaining alignment with theCsvToDtoImporterAPI.
251-252: LGTM! Invalid email tracking implemented.When
skipInvalidEmailis enabled, the code now properly increments theinvalid_emailcounter and records a translated error message, providing better visibility into data quality issues during import.
| * Handles full subscriber import workflow, including DB transactions and message dispatching. | ||
| * | ||
| * Note: Although this lives in the Service namespace, it acts as an *application service* — | ||
| * it orchestrates multiple domain services and manages transactions/flushes directly. | ||
| * This is an intentional exception for this complex import use case. | ||
| * |
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.
Domain layer purity concern: persistence operations in Domain.
While the docblock acknowledges this service uses transactions and flush() calls, the coding guidelines for src/Domain/** are strict: domain-layer code should not contain infrastructure persistence side effects like $entityManager->flush(), beginTransaction(), commit(), or rollback().
The guidelines recommend moving transaction orchestration and flush operations to application-layer Command handlers or background Jobs, with the Domain layer signaling write-intent via domain events, outbox patterns, or return values.
Consider refactoring this as an application-layer service that coordinates Domain services, rather than housing transaction management within the Domain namespace.
As per coding guidelines
"
Summary by CodeRabbit
-
- Enhanced invalid email detection and tracking during CSV imports, now recording invalid email errors in import statistics for better visibility.
-
- Improved internal CSV import workflow and service organization.
"Bug Fixes
Refactor
Thanks for contributing to phpList!