MaxProWeb / PhpMetrics

Static analysis tool for PHP

Home Page:http://www.phpmetrics.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PhpMetrics

Gives metrics about PHP project and classes.

License Build Status Scrutinizer Quality Score Latest Stable Version Dependency Status

Installation

With Composer:

php composer.phar global require 'halleck45/phpmetrics=@dev'

You can also download PhpMetrics as phar archive.

Usage

The command command vendor/bin/phpmetrics <folder or filename> will output:

Standard report

If you want to get the summary HTML report (with charts):

php ./bin/metrics.php --report-html=/path/of/your/choice.html <folder or filename>

No panic : you can read the How to read the HTML report page

Conditions of failure

Customizing the conditions of failure is very easy with the--failure-condition option. For example:

--failure-condition="average.maintenabilityIndex < 100 or sum.loc > 10000"

With this example, PhpMetrics script returns 1 if the average of Maintenability index is lower than 100 or if the total number of lines of code is greater than 10000.

You can also work with package:

--failure-condition="My/Package1/XXXX.average.bugs > 0.35"

Remember that in PhpMetrics package are file oriented (and not object oriented).

Conditions are evaluated with the Hoa Ruler component. Available operators are and, or, xor, not, = (is as an alias), !=, >, >=, <, <=, in and sum

List of availables metrics is documented here.

## Jenkins and IC integration

You'll find a complete tutorial in the documentation

You can easily export results to XML with the --report-xml option:

php ./bin/metrics.php --report-xml=/path/of/your/choice.xml <folder or filename>

You can also export results as violations (MessDetector report), in XML format with the --violations-xml option:

php ./bin/metrics.php --violations-xml=/path/of/your/choice.xml <folder or filename>

Contribute

In order to run unit tests, please install the dev dependencies:

curl -sS https://getcomposer.org/installer | php
php composer.phar install --dev

Then, to run the test suite:

./vendor/bin/phpunit

# Author

# Licence

See the LICENCE file.

About

Static analysis tool for PHP

http://www.phpmetrics.org/

License:MIT License