You are here

public function PHP_CodeCoverage_Report_HTML::process in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/HTML.php \PHP_CodeCoverage_Report_HTML::process()

Parameters

PHP_CodeCoverage $coverage:

string $target:

File

vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/HTML.php, line 65

Class

PHP_CodeCoverage_Report_HTML
Generates an HTML report from an PHP_CodeCoverage object.

Code

public function process(PHP_CodeCoverage $coverage, $target) {
  $target = $this
    ->getDirectory($target);
  $report = $coverage
    ->getReport();
  unset($coverage);
  if (!isset($_SERVER['REQUEST_TIME'])) {
    $_SERVER['REQUEST_TIME'] = time();
  }
  $date = date('D M j G:i:s T Y', $_SERVER['REQUEST_TIME']);
  $dashboard = new PHP_CodeCoverage_Report_HTML_Renderer_Dashboard($this->templatePath, $this->generator, $date, $this->lowUpperBound, $this->highLowerBound);
  $directory = new PHP_CodeCoverage_Report_HTML_Renderer_Directory($this->templatePath, $this->generator, $date, $this->lowUpperBound, $this->highLowerBound);
  $file = new PHP_CodeCoverage_Report_HTML_Renderer_File($this->templatePath, $this->generator, $date, $this->lowUpperBound, $this->highLowerBound);
  $directory
    ->render($report, $target . 'index.html');
  $dashboard
    ->render($report, $target . 'dashboard.html');
  foreach ($report as $node) {
    $id = $node
      ->getId();
    if ($node instanceof PHP_CodeCoverage_Report_Node_Directory) {
      if (!file_exists($target . $id)) {
        mkdir($target . $id, 0777, true);
      }
      $directory
        ->render($node, $target . $id . '/index.html');
      $dashboard
        ->render($node, $target . $id . '/dashboard.html');
    }
    else {
      $dir = dirname($target . $id);
      if (!file_exists($dir)) {
        mkdir($dir, 0777, true);
      }
      $file
        ->render($node, $target . $id . '.html');
    }
  }
  $this
    ->copyFiles($target);
}