function getCoverageReport($file){
$coverage = unserialize(file_get_contents("coverage.txt"));
$html = '';
if(!isset($coverage[$file])){
$html .= 'No coverage for this file
';
return $html;
}
$coveredLines = $coverage[$file];
$fileArray = file($file);
$html .= '' . "\n";
foreach($fileArray as $num => $line){
$linenum = $num+1;
$html .= '- ' . $linenum . '
' . "\n";
$class ="normal";
if(isset($coveredLines[$linenum]) && $coveredLines[$linenum] == 1){
$class = "covered";
}else if(isset($coveredLines[$linenum]) && $coveredLines[$linenum] == -1){
$class ="error";
}
$html .= '- ' . htmlspecialchars($line) . '
' . "\n";
}
$html .='
';
return $html;
}
if(isset($_GET["file"])){
$file = $_GET["file"];
echo 'Back to filelist';
echo 'Coverage for ' . $file . '
';
echo getCoverageReport($file);
}else{
echo "";
$it = new RecursiveDirectoryIterator($path);
foreach(new RecursiveIteratorIterator($it) as $file){
if(strpos($file->getPathname(), ".svn")){
continue;
}
echo '- ' . $file->getPathname() . '
';
}
}
?>