PHP code example of vitalyspirin / codecoverage

1. Go to this page and download the library: Download vitalyspirin/codecoverage 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/ */

    

vitalyspirin / codecoverage example snippets


use vitalyspirin\codecoverage\CodeCoverage;

$reportDir = 'CodeCoverageReports';  // directory for report files 
CodeCoverage::deleteAllReports($reportDir); // remove this if you need cumulative coverage
CodeCoverage::start();

$a = new A();

CodeCoverage::stop();
CodeCoverage::deleteTxtReports(); // remove this if you need cumulative coverage

CodeCoverage::$trackedFileList['test2'] = [];
CodeCoverage::$trackedFileList['test2'][] = realpath(dirname(__FILE__) . '/A.php');

$reportDir = 'CodeCoverageReports';  // directory for report files 
CodeCoverage::start($reportDir, "test2"); // "test2" is used to indicate which files should be analyzed.

$a = new A();

CodeCoverage::stop();



vitalyspirin\codecoverage\CodeCoverage::start(__DIR__ . '/codecoverage');

register_shutdown_function(function() {
    vitalyspirin\codecoverage\CodeCoverage::stop();
});