Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Dashboard.php

function Dashboard::coverageDistribution

Returns the data for the Class / Method Coverage Distribution chart.

1 call to Dashboard::coverageDistribution()
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 127

Class

Dashboard
@internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage

Namespace

SebastianBergmann\CodeCoverage\Report\Html

Code

private function coverageDistribution(array $classes) : array {
    $result = [
        'class' => [
            '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' => [
            '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 [
        'class' => json_encode(array_values($result['class'])),
        'method' => json_encode(array_values($result['method'])),
    ];
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal