PHP Depend - Software Metrics for PHP

Abstraction Instability Chart

To provide a flexible and extendable software, it is a good OO practice to reduce the dependencies between implementing classes. This could be achieved by developing against abstractions which means both, abstract classes and interfaces. By using abstractions instead of real implementation in the application you provide some sort of contract, that could be used by others to hook into the application with their own classes that fulfill the contract. Except the extensibility of an application a good abstraction reduces the risk of breaks in multiple subsystems when something was changed in a single package. But how to get rid of all these dependencies, doing this by hand will become an impossible job, at least for larger projects. At this point a tool should be used to assist the development process.

The A-I chart as it is generated by PHP_Depend is based on the whitepaper OO Design Quality Metrics - An Analysis of Dependencies [1] published by Robert C. Martin. It shows you the quality of your design in the terms of extensibility, reusability and maintainability. All these facts are influenced by the inter-package dependencies and the package abstraction that PHP_Depend visualizes in form of an abstract/instability chart.

PHP_Depend calculates the following metrics by counting classes, interfaces and dependencies.

With these values we can create a chart that visualizes the relationship between the instability (I) on the y-axis and the abstraction (A) on the x-axis.

Graphical view of PHP_Depend's metricsGraphical view of PHP_Depend's metrics

Because in a project not each package can achieve the optimal values of A = 1, I = 0 or A = 0, I = 1, we draw a diagonal between the two corners. This line is called the Main sequence and represents an average between abstraction (A) and instability (I). This means that packages near this line have a good mix between abstraction and instability. You can call these packages balanced. Because it is desirable for packages to be close to the Main sequence we have a fifth metric, the package distance (D) from this ideal.

1
http://www.objectmentor.com/resources/articles/oodmetrc.pdf
OO Design Quality Metrics - An Analysis of Dependencies; Robert C. Matrin; 1994

Reports

Overview Pyramid

Build on CloudBees button