Created
June 27, 2014 16:14
-
-
Save freemanirl/b9815028584e33dbcca5 to your computer and use it in GitHub Desktop.
Something to try and do a progress bar.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function showProgress($total, $current, $message = '') | |
{ | |
$this->cachedMessage = str_repeat("\x08", strlen($this->cachedMessage)); | |
$percentComplete = ($current/$total); | |
$completedCharacters = ceil($percentComplete * $this->totalProgressCharacters); | |
$bar = str_repeat("*", $completedCharacters); | |
$bar = str_pad($bar, $this->totalProgressCharacters, " "); | |
$bar = "[" . $bar . "] "; | |
$formatter = new \NumberFormatter('en_US', \NumberFormatter::PERCENT); | |
$this->cachedMessage .= $bar . $formatter->format($percentComplete) . ($message ? " - " . $message : ''); | |
$this->logger->info($this->cachedMessage); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment