Search by

teqnomaze / code-coverage

musthafasm

Check for the code coverage using the clover report of phpunit.

Package info

github.com/teqnomaze/code-coverage

Type:package

pkg:composer/teqnomaze/code-coverage

Statistics

Installs: 1 345

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

2.0.0 2026-10-25 17:49 UTC

This package is auto-updated.

Last update: 2026-10-25 18:18:01 UTC


README

A command-line tool that checks the code coverage percentage in PHPUnit's clover.xml report against a minimum threshold, and fails the build when coverage is too low.

Code Analysis

Requirements

  • PHP 8.2 or higher
  • Composer 2.x
  • A PHPUnit clover.xml report (generated with --coverage-clover)

Installation

Require the package as a development dependency in your project:

composer require --dev teqnomaze/code-coverage

Usage

vendor/bin/code-coverage <clover.xml> [threshold]
Argument Description Default
clover.xml Path to the clover.xml file generated by PHPUnit. Required
threshold Minimum acceptable coverage percentage, from 1 to 100. 80

Example:

vendor/bin/phpunit --coverage-clover build/clover.xml
vendor/bin/code-coverage build/clover.xml 90

Output:

Code coverage is 94%, which is above the accepted 90%

The displayed percentage is rounded down, while the pass or fail decision uses the exact value.

Exit codes

Code Meaning
0 Coverage meets or exceeds the threshold.
1 Coverage is below the threshold.
2 Usage error, missing or invalid file, or invalid threshold.

Changelog

All notable changes to this project are documented in CHANGELOG.md.

License

This project is licensed under the MIT License. See LICENSE.md for more information.