Filter from/to class #89
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Hi, I have an idea and I would like to know if it could be something interesting for the project. In very large applications, although php-class-diagram works correctly, you get diagrams that are difficult to navigate (too many arrows and classes). My idea is to add 2 more options: "--from-class" and "--to-class", which would filter only the classes referenced from/to a specific class, up to "--depth" levels. For example:
php-class-diagram --from="InvoiceGenerator" --depth=2 app
I have a working code draft but before refactoring it and writing tests I would like to know if it is worth it.
Thank you very much
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Activity
smeghead commentedon Nov 30, 2024
The idea of filtering classes and outputting class diagrams by specifying the class to be investigated is very interesting.
Do the two options
fromandtochange which classes are filtered depending on the direction of dependency?It would be great if you could provide a PR.
jose-ba commentedon Nov 30, 2024
Yes, that's the idea. For example, if I'm going to refactor a service class, I want to see a diagram of all the classes that depend on it (and the ones that depend on those up to
--depthlevels). This way, I can see all the classes that should be considered during a refactor (tests are a better way, but in some legacy projects tests are not available). That would be an use case for the--to-classfilter.Or maybe, I have a class that has many dependencies and I want to split it for better maintainability. Then, you could use the
--from-classfilter to see a "tree" of dependencies and detect potential points for splitting, or redundancies, cyclic dependencies and so on.I think that it can be useful for @pmaasz, who opened this PR: #76 It's similar to what he wants I think.
I will create a PR when I have time to refactor and test the code I have a little bit, because now it's just a draft (although it works, but options are hardcoded for example). I think that I can have it ready next week, or at least a draft that doesn't embarrass me 😂
Thank you