| 
21 | 21 | use GuzzleHttp\Event\ProgressEvent;  | 
22 | 22 | use GuzzleHttp\Utils;  | 
23 | 23 | use Symfony\Component\Console\Command\Command;  | 
 | 24 | +use Symfony\Component\Console\Helper\Helper;  | 
24 | 25 | use Symfony\Component\Console\Helper\ProgressBar;  | 
25 | 26 | use Symfony\Component\Console\Input\InputInterface;  | 
26 | 27 | use Symfony\Component\Console\Output\OutputInterface;  | 
@@ -146,10 +147,10 @@ protected function download()  | 
146 | 147 | 
 
  | 
147 | 148 |             if (null === $progressBar) {  | 
148 | 149 |                 ProgressBar::setPlaceholderFormatterDefinition('max', function (ProgressBar $bar) {  | 
149 |  | -                    return $this->formatSize($bar->getMaxSteps());  | 
 | 150 | +                    return Helper::formatMemory($bar->getMaxSteps());  | 
150 | 151 |                 });  | 
151 | 152 |                 ProgressBar::setPlaceholderFormatterDefinition('current', function (ProgressBar $bar) {  | 
152 |  | -                    return str_pad($this->formatSize($bar->getProgress()), 11, ' ', STR_PAD_LEFT);  | 
 | 153 | +                    return str_pad(Helper::formatMemory($bar->getProgress()), 11, ' ', STR_PAD_LEFT);  | 
153 | 154 |                 });  | 
154 | 155 | 
 
  | 
155 | 156 |                 $progressBar = new ProgressBar($this->output, $downloadSize);  | 
@@ -449,26 +450,6 @@ protected function checkPermissions()  | 
449 | 450 |         return $this;  | 
450 | 451 |     }  | 
451 | 452 | 
 
  | 
452 |  | -    /**  | 
453 |  | -     * Utility method to show the number of bytes in a readable format.  | 
454 |  | -     *  | 
455 |  | -     * @param int $bytes The number of bytes to format  | 
456 |  | -     *  | 
457 |  | -     * @return string The human readable string of bytes (e.g. 4.32MB)  | 
458 |  | -     */  | 
459 |  | -    protected function formatSize($bytes)  | 
460 |  | -    {  | 
461 |  | -        $units = array('B', 'KB', 'MB', 'GB', 'TB');  | 
462 |  | - | 
463 |  | -        $bytes = max($bytes, 0);  | 
464 |  | -        $pow = $bytes ? floor(log($bytes, 1024)) : 0;  | 
465 |  | -        $pow = min($pow, count($units) - 1);  | 
466 |  | - | 
467 |  | -        $bytes /= pow(1024, $pow);  | 
468 |  | - | 
469 |  | -        return number_format($bytes, 2).' '.$units[$pow];  | 
470 |  | -    }  | 
471 |  | - | 
472 | 453 |     /**  | 
473 | 454 |      * Formats the error message contained in the given Requirement item  | 
474 | 455 |      * using the optional line length provided.  | 
 | 
0 commit comments