Readme
Note
🇫🇷 Pour les lecteurs Francais, un article explorant la notion d'instabilité des composants est disponible sur laravel-france.com.
php-class-dependencies-analyzer is a tool that analyzes dependencies between classes within a specified path.
In an object-oriented project, classes naturally depend on each other, creating dependencies that introduce varying levels of instability, which can be quantified using this formula:
- Afferent coupling represents the number of components that depend on a given component.
- Efferent coupling indicates the number of dependencies that a component has on other components.
For example, the SummaryPresenter
class has an efferent coupling of 7, as it is depended on by 7 other classes.
The SummaryViewModel
class has an afferent coupling of 1, indicating it is used by only one other class.
Instability values range from 0 to 1:
- 0 indicates a fully stable class
- 1 represents a fully unstable class
A stable class has few dependencies and is relied upon by many components. Such classes are critical to the project and must be reliable and thoroughly tested.
An unstable class, on the other hand, has many dependencies but is seldom depended on by others. This type of class is easier to modify but is more susceptible to changes in its dependencies. It's advisable to monitor dependencies for unstable components and, where possible, replace highly unstable dependencies with abstractions.
Effectively managing these dependencies ensures maintainable, modular, and easily testable code.
This tool enables you to:
- Analyze class dependencies
- Analyze component dependencies
- Identify cyclic dependencies
- Spot fragile dependencies
Refer to the installation guide for details on installing this tool.