function File::renderTraitOrClassItems
1 call to File::renderTraitOrClassItems()
- File::renderItems in vendor/
phpunit/ php-code-coverage/ src/ Report/ Html/ Renderer/ File.php
File
-
vendor/
phpunit/ php-code-coverage/ src/ Report/ Html/ Renderer/ File.php, line 313
Class
- File
- @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
Namespace
SebastianBergmann\CodeCoverage\Report\HtmlCode
private function renderTraitOrClassItems(array $items, Template $template, Template $methodItemTemplate) : string {
$buffer = '';
if (empty($items)) {
return $buffer;
}
foreach ($items as $name => $item) {
$numMethods = 0;
$numTestedMethods = 0;
foreach ($item['methods'] as $method) {
if ($method['executableLines'] > 0) {
$numMethods++;
if ($method['executedLines'] === $method['executableLines']) {
$numTestedMethods++;
}
}
}
if ($item['executableLines'] > 0) {
$numClasses = 1;
$numTestedClasses = $numTestedMethods === $numMethods ? 1 : 0;
$linesExecutedPercentAsString = Percentage::fromFractionAndTotal($item['executedLines'], $item['executableLines'])->asString();
$branchesExecutedPercentAsString = Percentage::fromFractionAndTotal($item['executedBranches'], $item['executableBranches'])->asString();
$pathsExecutedPercentAsString = Percentage::fromFractionAndTotal($item['executedPaths'], $item['executablePaths'])->asString();
}
else {
$numClasses = 0;
$numTestedClasses = 0;
$linesExecutedPercentAsString = 'n/a';
$branchesExecutedPercentAsString = 'n/a';
$pathsExecutedPercentAsString = 'n/a';
}
$testedMethodsPercentage = Percentage::fromFractionAndTotal($numTestedMethods, $numMethods);
$testedClassesPercentage = Percentage::fromFractionAndTotal($numTestedMethods === $numMethods ? 1 : 0, 1);
$buffer .= $this->renderItemTemplate($template, [
'name' => $this->abbreviateClassName($name),
'numClasses' => $numClasses,
'numTestedClasses' => $numTestedClasses,
'numMethods' => $numMethods,
'numTestedMethods' => $numTestedMethods,
'linesExecutedPercent' => Percentage::fromFractionAndTotal($item['executedLines'], $item['executableLines'])->asFloat(),
'linesExecutedPercentAsString' => $linesExecutedPercentAsString,
'numExecutedLines' => $item['executedLines'],
'numExecutableLines' => $item['executableLines'],
'branchesExecutedPercent' => Percentage::fromFractionAndTotal($item['executedBranches'], $item['executableBranches'])->asFloat(),
'branchesExecutedPercentAsString' => $branchesExecutedPercentAsString,
'numExecutedBranches' => $item['executedBranches'],
'numExecutableBranches' => $item['executableBranches'],
'pathsExecutedPercent' => Percentage::fromFractionAndTotal($item['executedPaths'], $item['executablePaths'])->asFloat(),
'pathsExecutedPercentAsString' => $pathsExecutedPercentAsString,
'numExecutedPaths' => $item['executedPaths'],
'numExecutablePaths' => $item['executablePaths'],
'testedMethodsPercent' => $testedMethodsPercentage->asFloat(),
'testedMethodsPercentAsString' => $testedMethodsPercentage->asString(),
'testedClassesPercent' => $testedClassesPercentage->asFloat(),
'testedClassesPercentAsString' => $testedClassesPercentage->asString(),
'crap' => $item['crap'],
]);
foreach ($item['methods'] as $method) {
$buffer .= $this->renderFunctionOrMethodItem($methodItemTemplate, $method, ' ');
}
}
return $buffer;
}