You are here

private function ManageFilesForm::precentage in Minify JS 8

Same name and namespace in other branches
  1. 8.2 src/Form/ManageFilesForm.php \Drupal\minifyjs\Form\ManageFilesForm::precentage()

Helper function to format the savings percentage.

Parameters

stdClass $file:

1 call to ManageFilesForm::precentage()
ManageFilesForm::buildForm in src/Form/ManageFilesForm.php
Form constructor.

File

src/Form/ManageFilesForm.php, line 343

Class

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

Namespace

Drupal\minifyjs\Form

Code

private function precentage($file) {
  if ($file->minified_uri) {
    if ($file->minified_size > 0) {
      return round(($file->size - $file->minified_size) / $file->size * 100, 2) . '%';
    }
    return 0 . '%';
  }
  return '-';
}