/** * Calculates the Weight Method Per Class metric. * * @param PHP_Depend_Code_AbstractType $type The context type instance. * * @return integer[] * @since 1.0.6 */ private function calculateWmci(PHP_Depend_Code_AbstractType $type) { $ccn = array(); foreach ($type->getMethods() as $method) { $ccn[$method->getName()] = $this->cyclomaticAnalyzer->getCcn2($method); } return $ccn; }
/** * Calculates the crap index for the given callable. * * @param PHP_Depend_Code_AbstractCallable $callable The context callable. * * @return float */ private function calculateCrapIndex(PHP_Depend_Code_AbstractCallable $callable) { $report = $this->createOrReturnCoverageReport(); $complexity = $this->ccnAnalyzer->getCcn2($callable); $coverage = $report->getCoverage($callable); if ($coverage == 0) { return pow($complexity, 2) + $complexity; } else { if ($coverage > 99.5) { return $complexity; } } return pow($complexity, 2) * pow(1 - $coverage / 100, 3) + $complexity; }