Created
February 1, 2016 14:07
-
-
Save YarekTyshchenko/4092308fc5fa87ad1791 to your computer and use it in GitHub Desktop.
Clover XML Merger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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