protected function PHP_CodeCoverage_Report_Node_File::crap in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/phpunit/php-code-coverage/src/CodeCoverage/Report/Node/File.php \PHP_CodeCoverage_Report_Node_File::crap()
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
Parameters
int $ccn:
float $coverage:
Return value
string
1 call to PHP_CodeCoverage_Report_Node_File::crap()
- PHP_CodeCoverage_Report_Node_File::calculateStatistics in vendor/
phpunit/ php-code-coverage/ src/ CodeCoverage/ Report/ Node/ File.php - Calculates coverage statistics for the file.
File
- vendor/
phpunit/ php-code-coverage/ src/ CodeCoverage/ Report/ Node/ File.php, line 664
Class
- PHP_CodeCoverage_Report_Node_File
- Represents a file in the code coverage information tree.
Code
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);
}