Skip to content

Component Analyze

First analysis

This command analyzes the dependencies between components in a given path.

php class-dependencies-analyzer analyze:component <path> <components>

The <path> argument is the path to the directory to analyze.

The <components> argument is the list of components to analyze, example: app/Domain,app/Infrastructure/Repository.

Note

To obtain accurate results, it is crucial to analyze your entire codebase. If you perform a partial analysis, some nodes may appear incomplete.

Here are the results obtained from the above command :

  • Nc (Number of classes) : number of classes in the components.
  • Na (Number of abstractions) : number of abstractions (interface, abstract class) contained in the components.
  • A (Abstractness) : ratio of abstractions to the total number of methods in the components.
  • I (Instability) : instability of the components.

Components with a low instability (I close to 0) contain many unstable classes, this components are easier to modify but are more susceptible to changes in its dependencies.

Components with a high instability (I close to 1) contain many stable classes, this components are critical for the application and their business logic must be tested.

Components with a high abstractness (A close to 1) are totally abstract and should not contain any concrete implementation.

Graph rendering

The --graph option allows you to render the graph of the components.

php class-dependencies-analyzer analyze:component app 'App\Domain,App\Application,App\Infrastructure,App\Presenter'  --graph

The color of the nodes indicates the stability of the component:

  • A red component is strongly unstable.
  • A yellow component is unstable.
  • A green component is stable.

A red edge between two components indicates a weak dependency.