PHPackages                             permafrost-dev/coverage-check - 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. permafrost-dev/coverage-check

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

permafrost-dev/coverage-check
=============================

Check a project's code coverage, optionally enforcing a minimum value

v2.0.0(2y ago)1922.8k↓12.5%5[5 PRs](https://github.com/permafrost-dev/coverage-check/pulls)1MITPHPPHP ^8.0CI passing

Since Jul 3Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/permafrost-dev/coverage-check)[ Packagist](https://packagist.org/packages/permafrost-dev/coverage-check)[ Docs](https://github.com/permafrost-dev/coverage-check)[ GitHub Sponsors](https://github.com/sponsors/permafrost-dev)[ RSS](/packages/permafrost-dev-coverage-check/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (3)Versions (11)Used By (1)

coverage-check
==============

[](#coverage-check)

 [![coverage-check logo](https://camo.githubusercontent.com/b804db5c15c579facdc8bd58697db833a609e1ec72c85c3ed20bb274f14311ac/68747470733a2f2f7374617469632e7065726d6166726f73742e6465762f696d616765732f636f7665726167652d636865636b2f636f7665726167652d636865636b2d6c6f676f2d616c742e706e67)](https://camo.githubusercontent.com/b804db5c15c579facdc8bd58697db833a609e1ec72c85c3ed20bb274f14311ac/68747470733a2f2f7374617469632e7065726d6166726f73742e6465762f696d616765732f636f7665726167652d636865636b2f636f7665726167652d636865636b2d6c6f676f2d616c742e706e67)

 [![Package Version](https://camo.githubusercontent.com/092627acd4895e6468dd107d9c7a067692b0fafad755777a381f21b2f253286a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f7065726d6166726f73742d6465762f636f7665726167652d636865636b2e7376673f736f72743d73656d766572266c6f676f3d676974687562)](https://camo.githubusercontent.com/092627acd4895e6468dd107d9c7a067692b0fafad755777a381f21b2f253286a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f7065726d6166726f73742d6465762f636f7665726167652d636865636b2e7376673f736f72743d73656d766572266c6f676f3d676974687562) [![Downloads](https://camo.githubusercontent.com/2abcb3cc2bebabb24a8d3432d6cb4145cf3f02e852a672fa63f1ac89f3e262c5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7065726d6166726f73742d6465762f636f7665726167652d636865636b3f6c6f676f3d7061636b6167697374266c6f676f436f6c6f723d253233666666)](https://camo.githubusercontent.com/2abcb3cc2bebabb24a8d3432d6cb4145cf3f02e852a672fa63f1ac89f3e262c5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7065726d6166726f73742d6465762f636f7665726167652d636865636b3f6c6f676f3d7061636b6167697374266c6f676f436f6c6f723d253233666666) [![Test Run Status](https://github.com/permafrost-dev/coverage-check/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/permafrost-dev/coverage-check/actions/workflows/run-tests.yml/badge.svg?branch=main)
 [![license](https://camo.githubusercontent.com/13dc7710500fe6447f2230452d4ab92c1709bdd9de9bb049ddd9e83072426822/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7065726d6166726f73742d6465762f636f7665726167652d636865636b2e7376673f6c6f676f3d6f70656e736f75726365696e6974696174697665)](https://camo.githubusercontent.com/13dc7710500fe6447f2230452d4ab92c1709bdd9de9bb049ddd9e83072426822/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7065726d6166726f73742d6465762f636f7665726167652d636865636b2e7376673f6c6f676f3d6f70656e736f75726365696e6974696174697665) [![code coverage](https://camo.githubusercontent.com/99fcdc89e45c96ae1b8612be6305251cf62ccd3606488cb9532e52c807831b2a/68747470733a2f2f636f6465636f762e696f2f67682f7065726d6166726f73742d6465762f636f7665726167652d636865636b2f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d58617533594b35353438)](https://camo.githubusercontent.com/99fcdc89e45c96ae1b8612be6305251cf62ccd3606488cb9532e52c807831b2a/68747470733a2f2f636f6465636f762e696f2f67682f7065726d6166726f73742d6465762f636f7665726167652d636865636b2f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d58617533594b35353438)

---

Display the code coverage for a project using a clover.xml file, optionally enforcing a minimum code coverage percentage.

This package is designed to be used in your CI/CD or automated testing process *(i.e., using GitHub Workflows)*.

The concept for this package is based on [this article](https://ocramius.github.io/blog/automated-code-coverage-check-for-github-pull-requests-with-travis/).

---

``

> Note on PHP 7.x support: If you are using PHP 7.x, use the 1.x version of this package.

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

[](#installation)

```
composer require permafrost-dev/coverage-check --dev
```

Usage
-----

[](#usage)

Specify a valid clover.xml file and (optionally) a minimum coverage percentage to require using the `--require` or `-r` flag. A percentage can be either a whole number (integer) or a decimal (float).

If you specify the `--require/-r` flag, the check will fail if coverage percent is below the value you provide, and the process exit code will be non-zero.

If you don't specify the `--require/-r` flag, only the percentage of code coverage will be displayed and the exit code will always be zero.

```
./vendor/bin/coverage-check clover.xml
./vendor/bin/coverage-check clover.xml --require=50
./vendor/bin/coverage-check clover.xml -r 80.5
./vendor/bin/coverage-check clover.xml -m statement -r 75
./vendor/bin/coverage-check clover.xml --precision=1
```

Available Options
-----------------

[](#available-options)

OptionDescription`--coverage-only` or `-C`Only display the code coverage value`--metric` or `-m` ``Use the specified metric field for calculating coverage. Valid values are `element` *(default)*, `method`, or `statement``--precision` or `-p` ``Use the specified precision when calculating the code coverage percentage, where `` is an integer *(default: 4)*`--require` or `-r` ``Enforce a minimum code coverage value, where `` is an integer or decimal valueMetric fields
-------------

[](#metric-fields)

The field that is used to calculate code coverage can be specified using the `--metric=` or `-m ` option.

Valid field names are `element` *(the default)*, `statement`, and `method`.

Generating clover-format coverage files
---------------------------------------

[](#generating-clover-format-coverage-files)

PHPUnit can generate coverage reports in clover format:

```
./vendor/bin/phpunit --coverage-clover clover.xml
```

Sample Github Workflow
----------------------

[](#sample-github-workflow)

```
name: run-tests

on: [push, pull_request]

jobs:
  test:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: true
      matrix:
        os: [ubuntu-latest]
        php: [8.1, 8.0, 7.4, 7.3]

    name: P${{ matrix.php }} - ${{ matrix.os }}

    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, intl, iconv, fileinfo
          coverage: pcov

      - name: Setup problem matchers
        run: |
          echo "::add-matcher::${{ runner.tool_cache }}/php.json"
          echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

      - name: Install dependencies
        run: composer update --prefer-stable --prefer-dist --no-interaction

      - name: Execute tests
        run: ./vendor/bin/phpunit --coverage-clover clover.xml

      - name: Enforce 75% code coverage
        run: ./vendor/bin/coverage-check clover.xml --require=75 --precision=2
```

Testing
-------

[](#testing)

```
./vendor/bin/phpunit
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Patrick Organ](https://github.com/patinthehat)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance59

Moderate activity, may be stable

Popularity37

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 51.1% 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 ~196 days

Total

5

Last Release

996d ago

Major Versions

1.2.1 → v2.0.02023-08-27

PHP version history (2 changes)1.0.0PHP ^7.3|^8.0

v2.0.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/de8dcb8e8a47ddc1076a26721d1ce7b17e3066b53c4a5c5e9aa31367c1955a20?d=identicon)[permafrost-dev](/maintainers/permafrost-dev)

---

Top Contributors

[![patinthehat](https://avatars.githubusercontent.com/u/5508707?v=4)](https://github.com/patinthehat "patinthehat (69 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (37 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (29 commits)")

---

Tags

code-coveragecode-qualitycontinuous-integrationtest-automationtestingautomationcoveragecode qualitycode coveragepermafrost

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/permafrost-dev-coverage-check/health.svg)

```
[![Health](https://phpackages.com/badges/permafrost-dev-coverage-check/health.svg)](https://phpackages.com/packages/permafrost-dev-coverage-check)
```

###  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)[magento/magento2-functional-testing-framework

Magento2 Functional Testing Framework

15511.5M30](/packages/magento-magento2-functional-testing-framework)[dvdoug/behat-code-coverage

Generate Code Coverage reports for Behat tests

593.6M37](/packages/dvdoug-behat-code-coverage)[friends-of-phpspec/phpspec-code-coverage

Generate Code Coverage reports for PhpSpec tests

202.6M125](/packages/friends-of-phpspec-phpspec-code-coverage)[leanphp/behat-code-coverage

Generate Code Coverage reports for Behat tests

50359.8k2](/packages/leanphp-behat-code-coverage)

PHPackages © 2026

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