Calculates the Change Risk Anti-Patterns (CRAP) index for a unit of code based on its cyclomatic complexity and percentage of code coverage.
@since Method available since Release 1.2.0
integer $ccn:
float $coverage:
string
protected function crap($ccn, $coverage) {
if ($coverage == 0) {
return (string) pow($ccn, 2) + $ccn;
}
if ($coverage >= 95) {
return (string) $ccn;
}
return sprintf('%01.2F', pow($ccn, 2) * pow(1 - $coverage / 100, 3) + $ccn);
}