PHPMETRICS:
PHPMETRICS is another bautiful PHP code static analysis tool. This tool is evaluate the PHP code sand generate the analysis report. One of the Open source tool, hosted with MIT license. This tool is providing structured report. We can also integrate this tool with Jenkins & sonar etc. It will generate reports in many formats like XML, violations, HTML, CSV…
—————————————————-
PHPMetrics provides tons of metrics:
Complexity: Cyclomatic complexity, Myer’s interval, Relative system complexity
Volume: Vocabulary, Data complexity, Lines of code, Readability
Object Oriented: Lack of cohesion of methods, Coupling, Abstraction
Maintainability: Maintainability index, Halstead’s metrics, Effort
—————————————————-
Commands for Installation and execution:
$ mkdir cs_phpmetric //My Folder name
& cd cs_phpmetric //moving to my folder path
$ wget https://github.com/phpmetrics/PhpMetrics/raw/master/build/phpmetrics.phar
(or)
$ composer global require ‘phpmetrics/phpmetrics’ //by composer installation
$ chmod +x phpmetrics.phar
$ mv phpmetrics.phar /usr/local/bin/phpmetrics
—————————————————-
Generate HTML Report:
$phpmetrics –report-html=<Folder path where you want to save the report> <folder or filename of your project>
Ex: With below commad, i am executing & generating report fro sales Module.
$phpmetrics –report-html=/path/of/your/demo.html /var/www/magento2Project/app/code/Ecommerce/Sales
—————————————————-
Configuration options
• –report-html – This option is use to provide about Path to save report in HTML format
• –report-xml – If you want to generate report with xml format.
• –report-cli – With in terminal we can generate result.
• –violations-xml – Generate violations report in XML format.
• –report-csv – Generate report with CSV format.
• –report-json – Generate report with JSON format.
• –chart-bubbles – Generate Bubbles chart with path you specified location.It will be on SVG format. To generate this chart – Graphviz is required.
• –level – Depth of summary report.
• –extensions – Regex of extensions to include.
• –excluded-dirs – Regex of subdirectories to exclude.
• –symlinks – Enable following symlinks.
• –without-oop – If provided, tool will not extract any information about OOP model (faster).
• –ignore-errors – If provided, files will be analyzed even with syntax errors
• –failure-condition – Optional failure condition, in english. Example: –failure-condition=”average.maintainabilityIndex < 50 or sum.loc > 10000″
• –config – Config file (YAML). Example: –config=myconfig.yml
• –template-title – Title for the HTML summary report
For More Information, please refer below links:
https://phpmetrics.github.io/website/getting-started/
https://www.gitdetail.com/repositories/MrSecure/PhpMetrics/318853
https://phpmetrics.github.io/website/