You are here

protected function PcpService::calcNextPercentage in Profile Complete Percent 8

Calculates the percentage of fields completed when one more is 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::calcNextPercentage()
PcpService::getCompletePercentageData in src/PcpService.php
Builds array of pcp data.

File

src/PcpService.php, line 167

Class

PcpService
Class PcpService.

Namespace

Drupal\pcp

Code

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