PHPackages                             andrey-tech/phpunit-cobertura-formatter-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. andrey-tech/phpunit-cobertura-formatter-php

ActiveLibrary[Testing &amp; Quality](/categories/testing)

andrey-tech/phpunit-cobertura-formatter-php
===========================================

Tool to show code coverage metrics, measured by PHP Unit in Cobertura format, in console and CI/CD pipeline

1.0.2(5mo ago)01.3k↓33.3%MITPHPPHP ^8.3CI passing

Since Sep 7Pushed 5mo agoCompare

[ Source](https://github.com/andrey-tech/phpunit-cobertura-formatter-php)[ Packagist](https://packagist.org/packages/andrey-tech/phpunit-cobertura-formatter-php)[ Docs](https://github.com/andrey-tech/phpunit-cobertura-formatter-php)[ RSS](/packages/andrey-tech-phpunit-cobertura-formatter-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (13)Versions (8)Used By (0)

PHPUnit Cobertura Formatter
===========================

[](#phpunit-cobertura-formatter)

[![PHPUnit Cobertura Formatter logo](./assets/phpunit-cobertura-formatter-logo.png)](./assets/phpunit-cobertura-formatter-logo.png)

[![Latest Stable Version](https://camo.githubusercontent.com/f75d41a6c7852c1875ab2d629c229ff3905d93999245ad687718ffa0151b9cd2/68747470733a2f2f706f7365722e707567782e6f72672f616e647265792d746563682f706870756e69742d636f626572747572612d666f726d61747465722d7068702f76)](https://packagist.org/packages/andrey-tech/phpunit-cobertura-formatter-php)[![PHP workflow](https://github.com/andrey-tech/phpunit-cobertura-formatter-php/actions/workflows/php.yml/badge.svg?branch=master)](https://github.com/andrey-tech/phpunit-cobertura-formatter-php/actions/workflows/php.yml)[![Total Downloads](https://camo.githubusercontent.com/a60d587118b066569b7ad5ace3f9dc877bddb8e8e994cee04c5fc8a4bbbcbfe9/68747470733a2f2f706f7365722e707567782e6f72672f616e647265792d746563682f706870756e69742d636f626572747572612d666f726d61747465722d7068702f646f776e6c6f616473)](//packagist.org/packages/andrey-tech/phpunit-cobertura-formatter-php)[![PHP Version Require](https://camo.githubusercontent.com/929998826646dd63a5aed602ff81cd4999c6a378a4a0eb1f3250e500b00b11ad/68747470733a2f2f706f7365722e707567782e6f72672f616e647265792d746563682f706870756e69742d636f626572747572612d666f726d61747465722d7068702f726571756972652f706870)](https://packagist.org/packages/andrey-tech/phpunit-cobertura-formatter-php)[![License](https://camo.githubusercontent.com/25b903a2103e808ae9bf47b53c3b23fcbdf0fb2647877ae03fe0e4e8d4ea133e/68747470733a2f2f706f7365722e707567782e6f72672f616e647265792d746563682f706870756e69742d636f626572747572612d666f726d61747465722d7068702f6c6963656e7365)](https://packagist.org/packages/andrey-tech/phpunit-cobertura-formatter-php)

PHPUnit Cobertura Formatter is a tool to show code coverage metrics, measured by [PHP Unit](https://docs.phpunit.de/en/12.2/code-coverage.html#software-metrics-for-code-coverage) in [Cobertura](https://github.com/cobertura/cobertura) format, in console and CI/CD pipeline.

Installation
------------

[](#installation)

The PHPUnit Cobertura Formatter requires:

- [PHP](https://www.php.net) version 8.3 or higher
- [Composer](https://getcomposer.org)

To install via Composer:

```
composer require --dev andrey-tech/phpunit-cobertura-formatter-php
```

Command line options
--------------------

[](#command-line-options)

```
./vendor/bin/phpunit-cobertura-formatter
```

The PHPUnit Cobertura Formatter tool command line interface also accepts the following optional arguments:

- `--init` — Will generate a default config file `phpunit-cobertura-formatter.yml.dist` in current working directory.
- `--config-file` — The filepath to a custom config YAML file.
- `--filter-class-name` — The filter results by class name (regex).
- `--ignore-red-metrics-on-exit` — Will exit with a zero code, even "red" metrics exist.
- `--ignore-yellow-metrics-on-exit` — Will exit with a zero code, even "yellow" metrics exist.
- `--no-colors` — Disable colors in console.

An example command line of PHPUnit Cobertura Formatter tool:

```
./vendor/bin/phpunit-cobertura-formatter ./var/cobertura.xml --config-file=./phpunit-cobertura-formatter.yml.dist
```

An example of console output:

```
CLASS: App\Common\Service\Contract
+---------------------------+--------+--------+-----+------+
| METHOD                    | lcov   | bcov   | ccn | crap |
+---------------------------+--------+--------+-----+------+
| CLASS                     | 31.65  | 50.00  | 74  | 1822 |
| __construct               | 100.00 | 100.00 | 1   | 1    |
| getContractRules          | 0.00   | 0.00   | 5   | 30   |
| compareRules              | 75.00  | 70.00  | 7   | 7    |
| ruleAccept                | 100.00 | 100.00 | 31  | 31   |
| getPriority               | 88.24  | 79.17  | 9   | 9    |
| getContractsByRule        | 0.00   | 0.00   | 3   | 12   |
| getDefaultContracts       | 0.00   | 0.00   | 2   | 6    |
| createRuleDTO             | 0.00   | 0.00   | 7   | 56   |
| hasDefaultRule            | 0.00   | 0.00   | 3   | 12   |
| isDefaultRule             | 0.00   | 0.00   | 6   | 42   |
+---------------------------+--------+--------+-----+------+

Exit code: 2, Time: 17 ms, Memory: 1.85/4.00 MiB.

```

Software metrics
----------------

[](#software-metrics)

PHPUnit Cobertura Formatter tool shows metrics, measured by PHP Unit, in `green`, `yellow` and `red` colors in the console, according to boundaries for values, defined in configuration YAML file.

This table shows a list of the software metrics by PHPUnit Cobertura Formatter tool for classes and methods. The table also shows the default values for `red`/`yellow`/`green` boundaries of software metrics.

MetricDescriptionClassMethodlcov[Line Coverage](https://docs.phpunit.de/en/12.2/code-coverage.html#software-metrics-for-code-coverage), %0/1/1000/1/100bcov[Branch Coverage](https://docs.phpunit.de/en/12.2/code-coverage.html#software-metrics-for-code-coverage), %0/1/1000/1/100ccn[Cyclomatic Complexity Number](https://phpmd.org/rules/codesize.html#cyclomaticcomplexity)—11/8/7crap[Change Risk Analysis and Predictions Index (CRAP)](https://www.artima.com/weblogs/viewpost.jsp?thread=210575)—30/-/29Configuration YAML file
-----------------------

[](#configuration-yaml-file)

By PHPUnit Cobertura Formatter tool is looking for following configuration YAML files is current working directory:

- `phpunit-cobertura-formatter.yml`,
- `phpunit-cobertura-formatter.yml.dist`.

Configuration YAML file allows to set color boundaries for values of software metrics.

PHPUnit Cobertura Formatter tool currently defines three color boundaries:

ColorDescription`green`Ok`yellow`Warning`red`ErrorA white value means there are no defined color boundaries for this metric.

> You can also add/set custom colors and styles. See [How to Color and Style the Console Output](https://symfony.com/doc/current/console/coloring.html) in Symfony console.

The default configuration file:

```
colorizer:
  metrics:

    # Metrics of class
    class:

      lcov:
        green: [ 100, 100 ]
        yellow+bold: [ 1, 99 ]
        red+bold: [ 0, 1 ]

      bcov:
        green: [ 100, 100 ]
        yellow+bold: [ 1, 99 ]
        red+bold: [ 0, 1 ]

    # Metrics of method
    method:

      lcov:
        green: [ 100, 100 ]
        yellow+bold: [ 1, 99 ]
        red+bold: [ 0, 1 ]

      bcov:
        green: [ 100, 100 ]
        yellow+bold: [ 1, 99 ]
        red+bold: [ 0, 1 ]

      ccn:
        green: [ 1, 7 ]
        yellow+bold: [ 8, 10 ]
        red+bold: [ 11 ]

      crap:
        green: [ 0, 29 ]
        red+bold: [ 30 ]
```

Exit codes
----------

[](#exit-codes)

PHPUnit Cobertura Formatter tool defines four different exit codes:

CodeDescription0This exit code indicates that everything worked as expected without "red" or "yellow" metrics1This exit code indicates that an error/exception occurred which has interrupted tool during execution2This exit code means that tool has processed the Cobertura file with "red" metrics3This exit code means that tool has processed the Cobertura file with "yellow" metricsAuthors and Maintainers
-----------------------

[](#authors-and-maintainers)

The author and maintainer of PHPUnit Cobertura Formatter is [andrey-tech](https://github.com/andrey-tech).

License
-------

[](#license)

This tool is licensed under the [MIT license](./LICENSE).

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance71

Regular maintenance activity

Popularity19

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~15 days

Recently: every ~22 days

Total

7

Last Release

161d ago

Major Versions

0.3.0 → 1.0.02025-09-14

### Community

Maintainers

![](https://www.gravatar.com/avatar/de69f7116b4bbba0435826347eeea01c7c6d831ae5ca5325ccf0686e7ddb92b4?d=identicon)[andrey-tech](/maintainers/andrey-tech)

---

Top Contributors

[![andrey-tech](https://avatars.githubusercontent.com/u/51994444?v=4)](https://github.com/andrey-tech "andrey-tech (26 commits)")

---

Tags

ccncoberturacoveragecrapmetricsphpunitphpunitconsoletestcoverageMetricscoberturacrapccn

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/andrey-tech-phpunit-cobertura-formatter-php/health.svg)

```
[![Health](https://phpackages.com/badges/andrey-tech-phpunit-cobertura-formatter-php/health.svg)](https://phpackages.com/packages/andrey-tech-phpunit-cobertura-formatter-php)
```

###  Alternatives

[infection/infection

Infection is a Mutation Testing framework for PHP. The mutation adequacy score can be used to measure the effectiveness of a test set in terms of its ability to detect faults.

2.2k26.2M1.8k](/packages/infection-infection)[php-coveralls/php-coveralls

PHP client library for Coveralls API

51413.7M3.4k](/packages/php-coveralls-php-coveralls)[dvdoug/behat-code-coverage

Generate Code Coverage reports for Behat tests

593.6M37](/packages/dvdoug-behat-code-coverage)[fr3d/swagger-assertions

Test your API requests and responses against your swagger definition

138850.9k5](/packages/fr3d-swagger-assertions)[acquia/orca

A tool for testing a company's software packages together in the context of a realistic, functioning, best practices Drupal build

32902.4k](/packages/acquia-orca)[nimut/phpunit-merger

Merge multiple PHPUnit reports into one file

501.7M7](/packages/nimut-phpunit-merger)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
