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

Breadcrumb

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

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\Html

Code

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;
}

API Navigation

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