Skip to content

Weakness

A fragile dependency occurs when a class depends on another class that is more unstable. This situation can indicate poor design and suggests that the first class may be vulnerable to side effects stemming from its dependencies.

In this situation, component B is dependent on a component C that is more unstable than itself. This situation generates fragile coupling, which can lead to unintended side effects. Such dependencies can introduce bugs and create challenges for future evolution.

In a stable architecture, unstable components depend on stable components while adhering to the principle of decreasing instability.

First analysis

This command detects weaknesses in the specified path.

php class-dependencies-analyzer weakness <path>

Note

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

Delta

To filter results based on instability delta, you can use the --min-delta= argument:

php class-dependencies-analyzer analyze app --min-delta=0.1

The delta represents the difference in stability between a class and one of its dependencies. A larger delta indicates a higher likelihood that the first component will experience side effects due to its unstable dependency.

Filtering results

To display only a list of namespaces, use the --only= option.

php class-dependencies-analyzer weakness app --only='App\Domain,Infrastructure'

To exclude a list of namespaces, use the --exclude= option.

php class-dependencies-analyzer weakness app --exclude='App\Models'