diff --git a/c3.php b/c3.php index 72d273d..42ead4a 100644 --- a/c3.php +++ b/c3.php @@ -170,6 +170,17 @@ function __c3_build_crap4j_report(PHP_CodeCoverage $codeCoverage, $path) return $path . '.crap4j.xml'; } + function __c3_build_cobertura_report(PHP_CodeCoverage $codeCoverage, $path) + { + if (!class_exists(\SebastianBergmann\CodeCoverage\Report\Cobertura::class)) { + throw new Exception("Cobertura report requires php-code-coverage >= 9.2"); + } + $writer = new \SebastianBergmann\CodeCoverage\Report\Cobertura(); + $writer->process($codeCoverage, $path . '.cobertura.xml'); + + return $path . '.cobertura.xml'; + } + function __c3_build_phpunit_report(PHP_CodeCoverage $codeCoverage, $path) { $writer = new PHP_CodeCoverage_Report_XML(\PHPUnit_Runner_Version::id()); @@ -339,6 +350,13 @@ function __c3_clear() __c3_error($e->getMessage()); } return __c3_exit(); + case 'cobertura': + try { + __c3_send_file(__c3_build_cobertura_report($codeCoverage, $path)); + } catch (Exception $e) { + __c3_error($e->getMessage()); + } + return __c3_exit(); } } else { list($codeCoverage, ) = __c3_factory(null);