diff --git a/CHANGELOG.md b/CHANGELOG.md index 75092a6..ba812a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ This update introduces minor bug fixes. ### Fixed - Improve build efficiency by preventing duplicate merges - Updated file tracking in Runtime class + - Fixed division by zero in ConsoleProgressBar ## [2.0.3] - 2023-10-17 diff --git a/src/ncc/Utilities/ConsoleProgressBar.php b/src/ncc/Utilities/ConsoleProgressBar.php index 09ecaa6..b98f781 100644 --- a/src/ncc/Utilities/ConsoleProgressBar.php +++ b/src/ncc/Utilities/ConsoleProgressBar.php @@ -368,10 +368,16 @@ */ private function renderProgressBar(): string { - $hashes_count = round($this->progress_width * $this->value / $this->max_value); - $dashes_count = $this->progress_width - $hashes_count; - $percent_done = round($this->value * 100 / $this->max_value); + $hashes_count = 0; + $percent_done = 0; + if($this->max_value !== 0) + { + $hashes_count = round($this->progress_width * $this->value / $this->max_value); + $percent_done = round($this->value * 100 / $this->max_value); + } + + $dashes_count = $this->progress_width - $hashes_count; return ' [' . str_repeat('#', $hashes_count) . str_repeat('-', $dashes_count) . ']' . sprintf('%4s', $percent_done) . '%'; }