function ProgressBar::setProgress
3 calls to ProgressBar::setProgress()
- ProgressBar::advance in vendor/
symfony/ console/ Helper/ ProgressBar.php - Advances the progress output X steps.
- ProgressBar::finish in vendor/
symfony/ console/ Helper/ ProgressBar.php - Finishes the progress output.
- ProgressBar::start in vendor/
symfony/ console/ Helper/ ProgressBar.php - Starts the progress output.
File
-
vendor/
symfony/ console/ Helper/ ProgressBar.php, line 382
Class
- ProgressBar
- The ProgressBar provides helpers to display progress output.
Namespace
Symfony\Component\Console\HelperCode
public function setProgress(int $step) : void {
if ($this->max && $step > $this->max) {
$this->max = $step;
}
elseif ($step < 0) {
$step = 0;
}
$redrawFreq = $this->redrawFreq ?? ($this->max ?? 10) / 10;
$prevPeriod = $redrawFreq ? (int) ($this->step / $redrawFreq) : 0;
$currPeriod = $redrawFreq ? (int) ($step / $redrawFreq) : 0;
$this->step = $step;
$this->percent = match ($this->max) { null => 0,
0 => 1,
default => (double) $this->step / $this->max,
};
$timeInterval = microtime(true) - $this->lastWriteTime;
// Draw regardless of other limits
if ($this->max === $step) {
$this->display();
return;
}
// Throttling
if ($timeInterval < $this->minSecondsBetweenRedraws) {
return;
}
// Draw each step period, but not too late
if ($prevPeriod !== $currPeriod || $timeInterval >= $this->maxSecondsBetweenRedraws) {
$this->display();
}
}