function Dashboard::projectRisks
Returns the project risks according to the CRAP index.
1 call to Dashboard::projectRisks()
- Dashboard::render in vendor/
phpunit/ php-code-coverage/ src/ Report/ Html/ Renderer/ Dashboard.php
File
-
vendor/
phpunit/ php-code-coverage/ src/ Report/ Html/ Renderer/ Dashboard.php, line 247
Class
- Dashboard
- @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
Namespace
SebastianBergmann\CodeCoverage\Report\HtmlCode
private function projectRisks(array $classes, string $baseLink) : array {
$classRisks = [];
$methodRisks = [];
$result = [
'class' => '',
'method' => '',
];
foreach ($classes as $className => $class) {
foreach ($class['methods'] as $methodName => $method) {
if ($method['coverage'] < $this->thresholds
->highLowerBound() && $method['ccn'] > 1) {
$key = $methodName;
if ($className !== '*') {
$key = $className . '::' . $methodName;
}
$methodRisks[$key] = $method['crap'];
}
}
if ($class['coverage'] < $this->thresholds
->highLowerBound() && $class['ccn'] > count($class['methods'])) {
$classRisks[$className] = $class['crap'];
}
}
arsort($classRisks);
arsort($methodRisks);
foreach ($classRisks as $className => $crap) {
$result['class'] .= sprintf(' <tr><td><a href="%s">%s</a></td><td class="text-right">%d</td></tr>' . "\n", str_replace($baseLink, '', $classes[$className]['link']), $className, $crap);
}
foreach ($methodRisks as $methodName => $crap) {
[
$class,
$method,
] = explode('::', $methodName);
$result['method'] .= sprintf(' <tr><td><a href="%s"><abbr title="%s">%s</abbr></a></td><td class="text-right">%d</td></tr>' . "\n", str_replace($baseLink, '', $classes[$class]['methods'][$method]['link']), $methodName, $method, $crap);
}
return $result;
}