Skip to content

Commit d894967

Browse files
committed
Start HTML reporter branch support
1 parent 0048fb2 commit d894967

File tree

3 files changed

+39
-14
lines changed

3 files changed

+39
-14
lines changed

src/Report/Html/Facade.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ final class Facade
3838
*/
3939
private $highLowerBound;
4040

41+
/**
42+
* @var bool
43+
*/
44+
private $determineBranchCoverage = false;
45+
4146
public function __construct(int $lowUpperBound = 50, int $highLowerBound = 90, string $generator = '')
4247
{
4348
$this->generator = $generator;
@@ -69,6 +74,7 @@ public function process(CodeCoverage $coverage, string $target): void
6974
$this->lowUpperBound,
7075
$this->highLowerBound
7176
);
77+
$dashboard->setDetermineBranchCoverage($this->determineBranchCoverage);
7278

7379
$directory = new Directory(
7480
$this->templatePath,
@@ -77,6 +83,7 @@ public function process(CodeCoverage $coverage, string $target): void
7783
$this->lowUpperBound,
7884
$this->highLowerBound
7985
);
86+
$directory->setDetermineBranchCoverage($this->determineBranchCoverage);
8087

8188
$file = new File(
8289
$this->templatePath,
@@ -85,6 +92,7 @@ public function process(CodeCoverage $coverage, string $target): void
8592
$this->lowUpperBound,
8693
$this->highLowerBound
8794
);
95+
$file->setDetermineBranchCoverage($this->determineBranchCoverage);
8896

8997
$directory->render($report, $target . 'index.html');
9098
$dashboard->render($report, $target . 'dashboard.html');
@@ -113,6 +121,11 @@ public function process(CodeCoverage $coverage, string $target): void
113121
$this->copyFiles($target);
114122
}
115123

124+
public function setDetermineBranchCoverage(bool $determineBranchCoverage): void
125+
{
126+
$this->determineBranchCoverage = $determineBranchCoverage;
127+
}
128+
116129
/**
117130
* @throws RuntimeException
118131
*/

src/Report/Html/Renderer.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ abstract class Renderer
5050
*/
5151
protected $version;
5252

53+
/**
54+
* @var bool
55+
*/
56+
protected $determineBranchCoverage = false;
57+
5358
public function __construct(string $templatePath, string $generator, string $date, int $lowUpperBound, int $highLowerBound)
5459
{
5560
$this->templatePath = $templatePath;
@@ -60,6 +65,11 @@ public function __construct(string $templatePath, string $generator, string $dat
6065
$this->version = Version::id();
6166
}
6267

68+
public function setDetermineBranchCoverage(bool $determineBranchCoverage): void
69+
{
70+
$this->determineBranchCoverage = $determineBranchCoverage;
71+
}
72+
6373
protected function renderItemTemplate(\Text_Template $template, array $data): string
6474
{
6575
$numSeparator = ' / ';

src/Report/Html/Renderer/File.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,22 @@ protected function renderItems(FileNode $node): string
5454
$items = $this->renderItemTemplate(
5555
$template,
5656
[
57-
'name' => 'Total',
58-
'numClasses' => $node->getNumClassesAndTraits(),
59-
'numTestedClasses' => $node->getNumTestedClassesAndTraits(),
60-
'numMethods' => $node->getNumFunctionsAndMethods(),
61-
'numTestedMethods' => $node->getNumTestedFunctionsAndMethods(),
62-
'linesExecutedPercent' => $node->getLineExecutedPercent(false),
63-
'linesExecutedPercentAsString' => $node->getLineExecutedPercent(),
64-
'numExecutedLines' => $node->getNumExecutedLines(),
65-
'numExecutableLines' => $node->getNumExecutableLines(),
66-
'testedMethodsPercent' => $node->getTestedFunctionsAndMethodsPercent(false),
67-
'testedMethodsPercentAsString' => $node->getTestedFunctionsAndMethodsPercent(),
68-
'testedClassesPercent' => $node->getTestedClassesAndTraitsPercent(false),
69-
'testedClassesPercentAsString' => $node->getTestedClassesAndTraitsPercent(),
70-
'crap' => '<abbr title="Change Risk Anti-Patterns (CRAP) Index">CRAP</abbr>',
57+
'name' => 'Total',
58+
'numClasses' => $node->getNumClassesAndTraits(),
59+
'numTestedClasses' => $node->getNumTestedClassesAndTraits(),
60+
'numMethods' => $node->getNumFunctionsAndMethods(),
61+
'numTestedMethods' => $node->getNumTestedFunctionsAndMethods(),
62+
'linesExecutedPercent' => $node->getLineExecutedPercent(false),
63+
'linesExecutedPercentAsString' => $node->getLineExecutedPercent(),
64+
'numExecutedLines' => $node->getNumExecutedLines(),
65+
'numExecutableLines' => $node->getNumExecutableLines(),
66+
'testedMethodsPercent' => $node->getTestedFunctionsAndMethodsPercent(false),
67+
'testedMethodsPercentAsString' => $node->getTestedFunctionsAndMethodsPercent(),
68+
'testedClassesPercent' => $node->getTestedClassesAndTraitsPercent(false),
69+
'testedClassesPercentAsString' => $node->getTestedClassesAndTraitsPercent(),
70+
'testedBranchesPercent' => $node->getTestedBranchesPercent(false),
71+
'testedBranchesPercentAsString' => $node->getTestedBranchesPercent(),
72+
'crap' => '<abbr title="Change Risk Anti-Patterns (CRAP) Index">CRAP</abbr>',
7173
]
7274
);
7375

0 commit comments

Comments
 (0)