You are here

protected function PcpService::calcCurrentPercentage in Profile Complete Percent 8

Calculates the percentage of fields currently completed.

Parameters

int $completed: The number of fields completed.

int $total: The total number of fields.

Return value

int The calculated percentage.

1 call to PcpService::calcCurrentPercentage()
PcpService::getCompletePercentageData in src/PcpService.php
Builds array of pcp data.

File

src/PcpService.php, line 147

Class

PcpService
Class PcpService.

Namespace

Drupal\pcp

Code

protected function calcCurrentPercentage($completed, $total) {
  if ($total === 0) {
    return 0;
  }
  return round($completed * 100 / $total);
}