/**
* Calculates the crap index.
*
* @param string $testCase Name of the calling test case.
* @param integer $ccn The entire cyclomatic complexity number.
*
* @return array
*/
private function _calculateCrapIndex($testCase, $ccn)
{
$namespaces = self::parseCodeResourceForTest();
$options = array('coverage-report' => $this->_createCloverReportFile());
$analyzer = new CrapIndexAnalyzer($options);
$analyzer->addAnalyzer($this->_createCyclomaticComplexityAnalyzerMock($ccn));
$analyzer->analyze($namespaces);
$namespaces->rewind();
if ($namespaces->current()->getTypes()->count() > 0) {
return $analyzer->getNodeMetrics($namespaces->current()->getTypes()->current()->getMethods()->current());
}
return $analyzer->getNodeMetrics($namespaces->current()->getFunctions()->current());
}