PDepend\Metrics\Analyzer\CrapIndexAnalyzer::calculateCrapIndex PHP Method

calculateCrapIndex() private method

Calculates the crap index for the given callable.
private calculateCrapIndex ( PDepend\Source\AST\AbstractASTCallable $callable ) : float
$callable PDepend\Source\AST\AbstractASTCallable
return float
    private function calculateCrapIndex(AbstractASTCallable $callable)
    {
        $report = $this->createOrReturnCoverageReport();
        $complexity = $this->ccnAnalyzer->getCcn2($callable);
        $coverage = $report->getCoverage($callable);
        if ($coverage == 0) {
            return pow($complexity, 2) + $complexity;
        } elseif ($coverage > 99.5) {
            return $complexity;
        }
        return pow($complexity, 2) * pow(1 - $coverage / 100, 3) + $complexity;
    }