foreach ($modules->modules[0] as $module) { $state = 'ok'; $inputFile = __DIR__ . '/../' . $module->path . '/build/clover.xml'; $percentage = min(100, max(0, (int) $module->limit)); if (!file_exists($inputFile)) { continue; } $xml = new SimpleXMLElement(file_get_contents($inputFile)); $metrics = $xml->xpath('//metrics'); $totalElements = 0; $checkedElements = 0; foreach ($metrics as $metric) { $totalElements += (int) $metric['elements']; $checkedElements += (int) $metric['coveredelements']; } $coverage = (int) ceil($checkedElements / $totalElements * 100); if ($coverage < $percentage && (string) $module->mandatory == "true") { $error = true; $state = 'ko'; echo 'Code coverage is ' . $coverage . '%, which is below the accepted ' . $percentage . '% for ' . $module->name . PHP_EOL; } if ($coverage < $percentage && (string) $module->mandatory == "false") { $state = 'warn'; } $stats[] = array('name' => (string) $module->name, 'percent' => $percentage, 'coverage' => $coverage, 'state' => $state); } writeHtml($stats); writeCli($stats); if ($error) { exit(1); }
$sortedImages[date('YmdHis', filemtime($images[$i])) . $i] = $images[$i]; } # Sort images in array if ($newestImagesFirst) { krsort($sortedImages); } else { ksort($sortedImages); } } # Generate the HTML output writeHtml('<ul class="ins-imgs">'); foreach ($sortedImages as $image) { # Get the name of the image, stripped from image folder path and file type extension $name = 'Image name: ' . substr($image, strlen($imageFolder), strpos($image, '.') - strlen($imageFolder)); # Get the 'last modified' time stamp, make it human readable $lastModified = '(last modified: ' . date('F d Y H:i:s', filemtime($image)) . ')'; # Begin adding writeHtml('<li class="ins-imgs-li">'); writeHtml('<div class="ins-imgs-img"><a name="' . $image . '" href="#' . $image . '">'); writeHtml('<img src="' . $image . '" alt="' . $name . '" title="' . $name . '">'); writeHtml('</a></div>'); writeHtml('<div class="ins-imgs-label">' . $name . ' ' . $lastModified . '</div>'); writeHtml('</li>'); } writeHtml('</ul>'); writeHtml('<link rel="stylesheet" type="text/css" href="ins-imgs.css">'); # Convert HTML to JS function writeHtml($html) { echo "document.write('" . $html . "');\n"; }