You are here

private function MemcacheAdminSubscriber::statsPercent in Memcache API and Integration 8.2

Helper function. Calculate a percentage.

1 call to MemcacheAdminSubscriber::statsPercent()
MemcacheAdminSubscriber::displayStatistics in memcache_admin/src/EventSubscriber/MemcacheAdminSubscriber.php
Display statistics on page.

File

memcache_admin/src/EventSubscriber/MemcacheAdminSubscriber.php, line 124

Class

MemcacheAdminSubscriber
Memcache Admin Subscriber.

Namespace

Drupal\memcache_admin\EventSubscriber

Code

private function statsPercent($a, $b) {
  if ($a == 0) {
    return 0;
  }
  elseif ($b == 0) {
    return 100;
  }
  else {
    return $a / ($a + $b) * 100;
  }
}