From 631e86aa6fd6201e798cee85484f785a9004b813 Mon Sep 17 00:00:00 2001 From: Christopher Vagnetoft Date: Tue, 10 Jan 2017 13:53:54 +0100 Subject: [PATCH] Changed ratio to percent in status report --- src/MakePhar/PharBuilder.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/MakePhar/PharBuilder.php b/src/MakePhar/PharBuilder.php index a4c317a..736ec14 100644 --- a/src/MakePhar/PharBuilder.php +++ b/src/MakePhar/PharBuilder.php @@ -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()) {