Skip to content
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

Filter from/to class #89

Closed
jose-ba opened this issue Nov 29, 2024 · 2 comments
Closed

Filter from/to class #89

jose-ba opened this issue Nov 29, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@jose-ba
Copy link
Contributor

jose-ba commented Nov 29, 2024

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

@smeghead
Copy link
Owner

The idea of filtering classes and outputting class diagrams by specifying the class to be investigated is very interesting.
Do the two options from and to change which classes are filtered depending on the direction of dependency?
It would be great if you could provide a PR.

@smeghead smeghead added the enhancement New feature or request label Nov 30, 2024
@jose-ba
Copy link
Contributor Author

jose-ba commented 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 --depth levels). 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-class filter.

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-class filter 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants