Skip to content

Instantly share code, notes, and snippets.

@YarekTyshchenko
Created February 1, 2016 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save YarekTyshchenko/4092308fc5fa87ad1791 to your computer and use it in GitHub Desktop.
Save YarekTyshchenko/4092308fc5fa87ad1791 to your computer and use it in GitHub Desktop.
Clover XML Merger
<?php
$options = getopt("f:o:");
if (! isset($options['f'])) {
echo "Files have to be specified with -f\n";
exit(1);
}
if (! isset($options['o'])) {
echo "Output has to be specified with -o\n";
exit(1);
}
$files = $options['f'];
if (! is_array($files)) {
$files = array($files);
}
$output = $options['o'];
$buffer = '';
foreach ($files as $file) {
if (! file_exists($file)) {
echo "File '$file' doesn't exist\n";
exit(2);
}
$report = simplexml_load_file($file);
$buffer .= $report->project->asXML();
}
$fh = fopen($output ,'w');
if (! $fh) {
echo "Cannot open '$output' for writing\n";
exit(2);
}
fwrite($fh, sprintf('<?xml version="1.0" encoding="UTF-8"?><coverage>%s</coverage>', $buffer));
fclose($fh);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment