@@ -419,6 +419,35 @@ static private function initPlaceholderFormatters()
419419 '%elapsed% ' => function (ProgressBar $ bar ) {
420420 return str_pad (Helper::formatTime (time () - $ bar ->getStartTime ()), 6 , ' ' , STR_PAD_LEFT );
421421 },
422+ '%remaining% ' => function (ProgressBar $ bar ) {
423+ if (!$ bar ->getMaxSteps ()) {
424+ throw new \LogicException ('Unable to display the remaining time if the maximum number of steps is not set. ' );
425+ }
426+
427+ if (!$ bar ->getStep ()) {
428+ $ remaining = 0 ;
429+ } else {
430+ $ remaining = round ((time () - $ bar ->getStartTime ()) / $ bar ->getStep () * ($ bar ->getMaxSteps () - $ bar ->getStep ()));
431+ }
432+
433+ return str_pad (Helper::formatTime ($ remaining ), 6 , ' ' , STR_PAD_LEFT );
434+ },
435+ '%estimated% ' => function (ProgressBar $ bar ) {
436+ if (!$ bar ->getMaxSteps ()) {
437+ throw new \LogicException ('Unable to display the estimated time if the maximum number of steps is not set. ' );
438+ }
439+
440+ if (!$ bar ->getStep ()) {
441+ $ estimated = 0 ;
442+ } else {
443+ $ estimated = round ((time () - $ bar ->getStartTime ()) / $ bar ->getStep () * $ bar ->getMaxSteps ());
444+ }
445+
446+ return str_pad (Helper::formatTime ($ estimated ), 6 , ' ' , STR_PAD_LEFT );
447+ },
448+ '%memory% ' => function (ProgressBar $ bar ) {
449+ return str_pad (Helper::formatMemory (memory_get_usage (true )), 6 , ' ' , STR_PAD_LEFT );;
450+ },
422451 '%current% ' => function (ProgressBar $ bar ) {
423452 return str_pad ($ bar ->getStep (), $ bar ->getStepWidth (), ' ' , STR_PAD_LEFT );
424453 },
0 commit comments