protected function PHP_CodeCoverage_Report_HTML_Renderer_Dashboard::coverageDistribution in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/HTML/Renderer/Dashboard.php \PHP_CodeCoverage_Report_HTML_Renderer_Dashboard::coverageDistribution()
Returns the data for the Class / Method Coverage Distribution chart.
Parameters
array $classes:
Return value
array
1 call to PHP_CodeCoverage_Report_HTML_Renderer_Dashboard::coverageDistribution()
- PHP_CodeCoverage_Report_HTML_Renderer_Dashboard::render in vendor/
phpunit/ php-code-coverage/ src/ CodeCoverage/ Report/ HTML/ Renderer/ Dashboard.php
File
- vendor/
phpunit/ php-code-coverage/ src/ CodeCoverage/ Report/ HTML/ Renderer/ Dashboard.php, line 106
Class
- PHP_CodeCoverage_Report_HTML_Renderer_Dashboard
- Renders the dashboard for a PHP_CodeCoverage_Report_Node_Directory node.
Code
protected function coverageDistribution(array $classes) {
$result = array(
'class' => array(
'0%' => 0,
'0-10%' => 0,
'10-20%' => 0,
'20-30%' => 0,
'30-40%' => 0,
'40-50%' => 0,
'50-60%' => 0,
'60-70%' => 0,
'70-80%' => 0,
'80-90%' => 0,
'90-100%' => 0,
'100%' => 0,
),
'method' => array(
'0%' => 0,
'0-10%' => 0,
'10-20%' => 0,
'20-30%' => 0,
'30-40%' => 0,
'40-50%' => 0,
'50-60%' => 0,
'60-70%' => 0,
'70-80%' => 0,
'80-90%' => 0,
'90-100%' => 0,
'100%' => 0,
),
);
foreach ($classes as $class) {
foreach ($class['methods'] as $methodName => $method) {
if ($method['coverage'] == 0) {
$result['method']['0%']++;
}
elseif ($method['coverage'] == 100) {
$result['method']['100%']++;
}
else {
$key = floor($method['coverage'] / 10) * 10;
$key = $key . '-' . ($key + 10) . '%';
$result['method'][$key]++;
}
}
if ($class['coverage'] == 0) {
$result['class']['0%']++;
}
elseif ($class['coverage'] == 100) {
$result['class']['100%']++;
}
else {
$key = floor($class['coverage'] / 10) * 10;
$key = $key . '-' . ($key + 10) . '%';
$result['class'][$key]++;
}
}
return array(
'class' => json_encode(array_values($result['class'])),
'method' => json_encode(array_values($result['method'])),
);
}