Changed ratio to percent in status report

This commit is contained in:
Chris 2017-01-10 13:53:54 +01:00
parent 156bb62367
commit 631e86aa6f
1 changed files with 4 additions and 1 deletions

View File

@ -64,14 +64,17 @@ class PharBuilder
($vo) && printf("\r\e[K");
$phar->stopBuffering();
// Helper to format sizes
$formatSize = function ($s) {
$u = [ 'B', 'KB', 'MB', 'GB' ];
while (count($u)>1 && ($s > 1024)) { $s /= 1024; array_shift($u); }
return sprintf("%.2f%s", $s, array_shift($u));
};
// Format the status
$str_tot = $formatSize($size_tot);
$str_min = $formatSize($size_min);
log_debug("Size: {$str_tot}, Minified: {$str_min}");
$str_rat = sprintf("%.2f%%", 100/$str_tot*$str_min);
log_debug("Size: %s, Minified: %s (%s)", $str_tot, $str_min, $str_rat);
// Create stub
if ($this->manifest->getIsLibrary()) {