-
Notifications
You must be signed in to change notification settings - Fork 0
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
Refactoring into clean architecture #4
Conversation
Warning Rate Limit Exceeded@DeGraciaMathieu has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 31 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. WalkthroughThe project underwent a significant restructuring and enhancement, focusing on improving file and word handling through new and updated classes across application, domain, and infrastructure layers. Key additions include interfaces for input and output handling, service adapters for file and analysis operations, and a variety of utility classes for managing entities and value objects. This comprehensive update aims to streamline processes and expand functionality within the codebase. Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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: 4
Out of diff range and nitpick comments (1)
tests/Builders/FileAggregatorBuilder.php (1)
29-36
: Method correctly creates a FileEntity from stub data. Ensure this method is used only in testing contexts due to hardcoded paths.
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
composer.lock
is excluded by!**/*.lock
Files selected for processing (31)
- app/Application/UseCases/InspectHandler.php (1 hunks)
- app/Application/UseCases/InspectInput.php (1 hunks)
- app/Application/UseCases/InspectOutput.php (1 hunks)
- app/Domain/Aggregators/FileAggregator.php (1 hunks)
- app/Domain/Aggregators/WordAggregator.php (1 hunks)
- app/Domain/Entities/FileEntity.php (1 hunks)
- app/Domain/Entities/WordEntity.php (1 hunks)
- app/Domain/Ports/AnalyzeService.php (1 hunks)
- app/Domain/Ports/FileService.php (1 hunks)
- app/Domain/ValueObjects/Path.php (1 hunks)
- app/Infrastructure/Analyze/Adapters/AnalyzeServiceAdapter.php (1 hunks)
- app/Infrastructure/Analyze/Mappers/PhpParserWordMapper.php (1 hunks)
- app/Infrastructure/Analyze/Nodes/NodeExtractor.php (1 hunks)
- app/Infrastructure/Analyze/Nodes/NodeValidator.php (1 hunks)
- app/Infrastructure/Analyze/Visitors/ClassVisitor.php (2 hunks)
- app/Infrastructure/File/Adapters/FileServiceAdapter.php (1 hunks)
- app/Infrastructure/File/Mappers/FileFinderMapper.php (1 hunks)
- app/Presenter/Commands/InspectCommand.php (1 hunks)
- app/Presenter/Commands/InspectCommandInput.php (1 hunks)
- app/Presenter/Commands/InspectCommandOutput.php (1 hunks)
- app/Providers/AppServiceProvider.php (2 hunks)
- composer.json (2 hunks)
- config/commands.php (1 hunks)
- tests/Builders/FileAggregatorBuilder.php (1 hunks)
- tests/Builders/builders.php (1 hunks)
- tests/Builders/stubs/Foo.php (1 hunks)
- tests/Unit/Application/InspectTestCase.php (1 hunks)
- tests/Unit/Domain/Aggregators/WordAggregatorTest.php (1 hunks)
- tests/Unit/Domain/Entities/WordEntityTest.php (1 hunks)
- tests/Unit/Infrastructure/Nodes/NodeExtractorTest.php (1 hunks)
- tests/Unit/Infrastructure/Nodes/NodeValidatorTest.php (1 hunks)
Files skipped from review due to trivial changes (9)
- app/Application/UseCases/InspectInput.php
- app/Domain/Aggregators/FileAggregator.php
- app/Domain/Aggregators/WordAggregator.php
- app/Domain/Entities/FileEntity.php
- app/Domain/Entities/WordEntity.php
- app/Domain/Ports/FileService.php
- app/Infrastructure/Analyze/Nodes/NodeExtractor.php
- config/commands.php
- tests/Unit/Domain/Aggregators/WordAggregatorTest.php
Additional comments not posted (42)
tests/Builders/builders.php (1)
5-7
: FunctionfileAggregator
implementation looks good.This function correctly creates and returns an instance of
FileAggregatorBuilder
.app/Infrastructure/Analyze/Nodes/NodeValidator.php (1)
Line range hint
7-13
: Static methods for node type checking are correctly implemented.The methods
isAVariable
andisAMethod
use appropriateinstanceof
checks and are well-implemented for their intended purpose.app/Domain/Ports/AnalyzeService.php (1)
10-15
: MethodgetWords
is well-documented and appropriately designed.The documentation clearly describes the method's functionality and its parameters. The use of
FileAggregator
andWordAggregator
is appropriate and aligns with the method's purpose.app/Presenter/Commands/InspectCommandInput.php (1)
8-23
: ClassInspectCommandInput
is well-implemented and follows good practices.The class correctly implements the
InspectInput
interface, uses type safety with thePath
class, and properly encapsulates its properties.app/Infrastructure/Analyze/Mappers/PhpParserWordMapper.php (1)
8-27
: ClassPhpParserWordMapper
is correctly implemented and effectively usesWordAggregator
.The methods
map
andaggregate
are well-implemented, effectively adding words to and retrieving words from theWordAggregator
.app/Infrastructure/File/Adapters/FileServiceAdapter.php (1)
13-15
: Constructor correctly initializes dependencies.app/Infrastructure/Analyze/Visitors/ClassVisitor.php (2)
7-7
: Constructor correctly initializes control flag for node parsing.
24-24
: Method correctly processes nodes and accumulates words.tests/Builders/FileAggregatorBuilder.php (3)
12-15
: Constructor correctly initializes a new FileAggregator.
17-22
: Method correctly adds a file entity and supports method chaining.
24-27
: Method correctly builds and returns the FileAggregator.app/Infrastructure/File/Mappers/FileFinderMapper.php (2)
11-14
: Constructor correctly initializes a FileAggregator for accumulating file entities.
16-26
: Method correctly maps files to FileAggregator using a clear and efficient loop structure.app/Providers/AppServiceProvider.php (1)
35-36
: Service bindings are correctly configured for FileService and AnalyzeService.tests/Unit/Domain/Entities/WordEntityTest.php (3)
12-18
: Test correctly asserts that words are transformed to lowercase.
20-26
: Test correctly asserts that common words are not ignored.
29-43
: Test correctly uses a data provider to assert that specific words can be ignored.app/Application/UseCases/InspectHandler.php (2)
13-17
: Constructor correctly initializes services needed for the inspection process.
19-42
: Method correctly orchestrates the inspection process and handles exceptions appropriately.app/Presenter/Commands/InspectCommand.php (1)
31-42
: Method correctly sets up and executes the inspection command.tests/Unit/Infrastructure/Nodes/NodeValidatorTest.php (4)
9-9
: Namespace update aligns with the new architecture.
Line range hint
13-21
: Test method correctly checks if a node is a variable.
Line range hint
23-31
: Test method correctly checks if a node is a method.
Line range hint
33-41
: Test method effectively handles unexpected node types, enhancing robustness.app/Presenter/Commands/InspectCommandOutput.php (5)
15-21
: Constructor correctly initializes dependencies for rendering views and HTML.
23-26
: Method effectively uses helper function to display greeting message.
28-35
: Method efficiently handles presentation logic by separating concerns of data manipulation and rendering.
37-40
: Error handling method correctly utilizes helper function to display errors.
42-52
: Private methods for HTML handling are well encapsulated and utilize appropriate components.composer.json (2)
22-22
: Updated dependencies reflect the new requirements for the project.
39-41
: Addition of development-specific file to autoload configuration enhances development experience.tests/Unit/Infrastructure/Nodes/NodeExtractorTest.php (4)
8-8
: Namespace update aligns with the new architecture.
Line range hint
10-26
: Test method effectively uses data providers to test variable name splitting functionality.
Line range hint
28-44
: Test method correctly checks if a method name can be split into words.
Line range hint
46-62
: Test method effectively handles complex cases of nested variable names.app/Infrastructure/Analyze/Adapters/AnalyzeServiceAdapter.php (4)
14-19
: Constructor correctly initializes dependencies for parsing and mapping words.
21-30
: Method efficiently handles word aggregation by separating concerns of file handling and aggregation logic.
32-41
: Method effectively uses visitor pattern to process files and extract words.
43-59
: Private methods for handling visitors are well encapsulated and utilize appropriate components.tests/Unit/Application/InspectTestCase.php (3)
17-30
: Setup method correctly initializes mocks and dependencies for testing.
32-40
: Test method effectively simulates and tests the inspection use case for counting words.
42-87
: Private helper methods are well-structured and contribute to a clear and maintainable test setup.
public function all(Path $path): FileAggregator | ||
{ | ||
$finder = new FileFinder( | ||
basePath: getcwd(), | ||
); | ||
|
||
$files = $finder->getFiles( | ||
$path->value(), | ||
); | ||
|
||
return $this->mapper->map($files); | ||
} |
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.
Method correctly retrieves and maps files. Consider making the base path configurable for greater flexibility.
public function all(Path $path, string $basePath = null): FileAggregator
{
$basePath = $basePath ?? getcwd();
$finder = new FileFinder(basePath: $basePath);
$files = $finder->getFiles($path->value());
return $this->mapper->map($files);
}
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.
YAGNI
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.
@DeGraciaMathieu, I understand and respect the "YAGNI" principle you're applying. Keeping the code simple until a need is clearly identified is a sound strategy, especially in projects where requirements are evolving.
The suggestion to make the base path configurable was aimed at enhancing flexibility, particularly for different deployment environments or testing scenarios. However, if the current setup meets the project's needs without this flexibility, it makes sense to keep things straightforward as you suggested.
Should the need for this feature arise in the future, it can be revisited. Thank you for your input, and please let me know if there's anything else I can assist with!
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: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
composer.lock
is excluded by!**/*.lock
Files selected for processing (31)
- app/Application/UseCases/InspectHandler.php (1 hunks)
- app/Application/UseCases/InspectInput.php (1 hunks)
- app/Application/UseCases/InspectOutput.php (1 hunks)
- app/Domain/Aggregators/FileAggregator.php (1 hunks)
- app/Domain/Aggregators/WordAggregator.php (1 hunks)
- app/Domain/Entities/FileEntity.php (1 hunks)
- app/Domain/Entities/WordEntity.php (1 hunks)
- app/Domain/Ports/AnalyzeService.php (1 hunks)
- app/Domain/Ports/FileService.php (1 hunks)
- app/Domain/ValueObjects/Path.php (1 hunks)
- app/Infrastructure/Analyze/Adapters/AnalyzeServiceAdapter.php (1 hunks)
- app/Infrastructure/Analyze/Mappers/PhpParserWordMapper.php (1 hunks)
- app/Infrastructure/Analyze/Nodes/NodeExtractor.php (1 hunks)
- app/Infrastructure/Analyze/Nodes/NodeValidator.php (1 hunks)
- app/Infrastructure/Analyze/Visitors/ClassVisitor.php (2 hunks)
- app/Infrastructure/File/Adapters/FileServiceAdapter.php (1 hunks)
- app/Infrastructure/File/Mappers/FileFinderMapper.php (1 hunks)
- app/Presenter/Commands/InspectCommand.php (1 hunks)
- app/Presenter/Commands/InspectCommandInput.php (1 hunks)
- app/Presenter/Commands/InspectCommandOutput.php (1 hunks)
- app/Providers/AppServiceProvider.php (2 hunks)
- composer.json (2 hunks)
- config/commands.php (1 hunks)
- tests/Builders/FileAggregatorBuilder.php (1 hunks)
- tests/Builders/builders.php (1 hunks)
- tests/Builders/stubs/Foo.php (1 hunks)
- tests/Unit/Application/InspectTestCase.php (1 hunks)
- tests/Unit/Domain/Aggregators/WordAggregatorTest.php (1 hunks)
- tests/Unit/Domain/Entities/WordEntityTest.php (1 hunks)
- tests/Unit/Infrastructure/Nodes/NodeExtractorTest.php (1 hunks)
- tests/Unit/Infrastructure/Nodes/NodeValidatorTest.php (1 hunks)
Files skipped from review due to trivial changes (1)
- tests/Builders/builders.php
Files skipped from review as they are similar to previous changes (30)
- app/Application/UseCases/InspectHandler.php
- app/Application/UseCases/InspectInput.php
- app/Application/UseCases/InspectOutput.php
- app/Domain/Aggregators/FileAggregator.php
- app/Domain/Aggregators/WordAggregator.php
- app/Domain/Entities/FileEntity.php
- app/Domain/Entities/WordEntity.php
- app/Domain/Ports/AnalyzeService.php
- app/Domain/Ports/FileService.php
- app/Domain/ValueObjects/Path.php
- app/Infrastructure/Analyze/Adapters/AnalyzeServiceAdapter.php
- app/Infrastructure/Analyze/Mappers/PhpParserWordMapper.php
- app/Infrastructure/Analyze/Nodes/NodeExtractor.php
- app/Infrastructure/Analyze/Nodes/NodeValidator.php
- app/Infrastructure/Analyze/Visitors/ClassVisitor.php
- app/Infrastructure/File/Adapters/FileServiceAdapter.php
- app/Infrastructure/File/Mappers/FileFinderMapper.php
- app/Presenter/Commands/InspectCommand.php
- app/Presenter/Commands/InspectCommandInput.php
- app/Presenter/Commands/InspectCommandOutput.php
- app/Providers/AppServiceProvider.php
- composer.json
- config/commands.php
- tests/Builders/FileAggregatorBuilder.php
- tests/Builders/stubs/Foo.php
- tests/Unit/Application/InspectTestCase.php
- tests/Unit/Domain/Aggregators/WordAggregatorTest.php
- tests/Unit/Domain/Entities/WordEntityTest.php
- tests/Unit/Infrastructure/Nodes/NodeExtractorTest.php
- tests/Unit/Infrastructure/Nodes/NodeValidatorTest.php
Quality Gate passedIssues Measures |
Summary by CodeRabbit
New Features
Enhancements
Refactor
Documentation
Tests
Chores
composer.json
and configurations to support new dependencies and command paths.