This script will read the XML coverage result and calculates the coverage score. Based on the given threshold the script will exit(0) if the coverage is higher than the threshold or exit(1) if the coverage is lower than the threshold.
composer require --dev babeuloula/phpunit-coverage-checker
vendor/bin/coverage-checker <path/to/coverage/index.xml> <threshold>
Example:
./vendor/bin/phpunit --coverage-xml ./coverage
vendor/bin/coverage-checker coverage/xml/index.xml 80
Thanks to richardregeer and cylab.be.