You are here

private function ManageFilesForm::format_filesize in Minify JS 8

Helper function to format the filesize.

Parameters

int $size:

2 calls to ManageFilesForm::format_filesize()
ManageFilesForm::buildForm in src/Form/ManageFilesForm.php
Form constructor.
ManageFilesForm::minified_filesize in src/Form/ManageFilesForm.php
Helper function to format the minified filesize.

File

src/Form/ManageFilesForm.php, line 283

Class

ManageFilesForm
Displays a list of detected javascript files and allows actions to be performed on them

Namespace

Drupal\minifyjs\Form

Code

private function format_filesize($size) {
  if ($size) {
    $suffixes = array(
      '',
      'k',
      'M',
      'G',
      'T',
    );
    $base = log($size) / log(1024);
    $base_floor = floor($base);
    return round(pow(1024, $base - $base_floor), 2) . $suffixes[$base_floor];
  }
  return 0;
}