PHP code example of gergelyrozsas / clover-diff

1. Go to this page and download the library: Download gergelyrozsas/clover-diff library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gergelyrozsas / clover-diff example snippets




use GergelyRozsas\CloverDiff\Factory;
use GergelyRozsas\CloverDiff\Node\Iterator\RecursiveNodeIterator;

$diff = Factory::getCloverDiff();
$report = $diff->compare([
  '/path/to/clover1.xml',
  '/path/to/clover2.xml',
]);

$iterator = new \RecursiveIteratorIterator(
  new RecursiveNodeIterator($report),
  \RecursiveIteratorIterator::SELF_FIRST
); 

/** @var \GergelyRozsas\CloverDiff\Node\NodeInterface $node */
foreach ($iterator as $node) {
  foreach ($node->getRevisions() as $revision) {
    echo \vsprintf("Coverage for %s on %s was %.2f%%.\n", [
      \implode('/', $node->getPath()),
      \date('Y-m-d H:i:s', $revision->getTimestamp()),
      \round(100 * $revision->getCoveredElements() / $revision->getElements()),
    ]);
  }
}



use GergelyRozsas\CloverDiff\Factory;

$diff = Factory::getCloverDiff();
$report = $diff->compare([
  '/path/to/clover1.xml',
  '/path/to/clover2.xml',
]);

$generator = Factory::getHtmlReport();
$options = $generator->process($report);

echo "The report was generated into the '{$options['target']}' directory.\n";