1 2 3 4 5 6 7 8 9 10 11 12
<?php /** * Calculate the percentage of success for a test * * @param array $suiteResults * @return float Percent */ function percent($suiteResults) { $sum = $suiteResults['pass'] + $suiteResults['fail']; return round($suiteResults['pass'] * 100 / max($sum, 1), 2); }