public function calculatePercent($number, $total) { if ($number == 0 || $total == 0) { return '0%'; } if ($number >= $total) { return '100%'; } return intval($number / $total * 100).'%'; }