public static function PHP_CodeCoverage_Util::percent in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/phpunit/php-code-coverage/src/CodeCoverage/Util.php \PHP_CodeCoverage_Util::percent()
Parameters
float $a:
float $b:
Return value
float ($a / $b) * 100
16 calls to PHP_CodeCoverage_Util::percent()
- PHP_CodeCoverage_Report_HTML_Renderer_File::renderFunctionOrMethodItem in vendor/
phpunit/ php-code-coverage/ src/ CodeCoverage/ Report/ HTML/ Renderer/ File.php - PHP_CodeCoverage_Report_HTML_Renderer_File::renderTraitOrClassItems in vendor/
phpunit/ php-code-coverage/ src/ CodeCoverage/ Report/ HTML/ Renderer/ File.php - PHP_CodeCoverage_Report_Node::getLineExecutedPercent in vendor/
phpunit/ php-code-coverage/ src/ CodeCoverage/ Report/ Node.php - Returns the percentage of executed lines.
- PHP_CodeCoverage_Report_Node::getTestedClassesAndTraitsPercent in vendor/
phpunit/ php-code-coverage/ src/ CodeCoverage/ Report/ Node.php - Returns the percentage of traits that has been tested.
- PHP_CodeCoverage_Report_Node::getTestedClassesPercent in vendor/
phpunit/ php-code-coverage/ src/ CodeCoverage/ Report/ Node.php - Returns the percentage of classes that has been tested.
File
- vendor/
phpunit/ php-code-coverage/ src/ CodeCoverage/ Util.php, line 23
Class
- PHP_CodeCoverage_Util
- Utility methods.
Code
public static function percent($a, $b, $asString = false, $fixedWidth = false) {
if ($asString && $b == 0) {
return '';
}
if ($b > 0) {
$percent = $a / $b * 100;
}
else {
$percent = 100;
}
if ($asString) {
if ($fixedWidth) {
return sprintf('%6.2F%%', $percent);
}
return sprintf('%01.2F%%', $percent);
}
else {
return $percent;
}
}