Gathering metrics in PHP
In this section, we want to have a look at the tools there are in the PHP world to gather code quality metrics. As you will see shortly, these metrics are not just numbers – they will allow you to make educated guesses about how much effort it will take to refactor code. They will also help you to identify the parts of the code that will require the most attention.
Again, we have curated a selection of tools for you:
phploc
- PHP Depend
- PhpMetrics
phploc
As we learned in the previous section, the abbreviation LOC stands for lines of code, so the name already reveals the main purpose of this tool. Being a basic metric, it already tells us quite a few things about a code base. phploc
also provides further metrics, such as the CC, so it is worth having a closer look at it.
Installation and usage
The author of this tool, Sebastian Bergmann, is well known for phpunit
, the de facto standard for automated tests in the PHP world...