You are here

public function ProgressBar::setProgress in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/console/Helper/ProgressBar.php \Symfony\Component\Console\Helper\ProgressBar::setProgress()

Sets the current progress.

Parameters

int $step The current progress:

Throws

\LogicException

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::setCurrent in vendor/symfony/console/Helper/ProgressBar.php
Sets the current progress.

File

vendor/symfony/console/Helper/ProgressBar.php, line 389

Class

ProgressBar
The ProgressBar provides helpers to display progress output.

Namespace

Symfony\Component\Console\Helper

Code

public function setProgress($step) {
  $step = (int) $step;
  if ($step < $this->step) {
    throw new \LogicException('You can\'t regress the progress bar.');
  }
  if ($this->max && $step > $this->max) {
    $this->max = $step;
  }
  $prevPeriod = (int) ($this->step / $this->redrawFreq);
  $currPeriod = (int) ($step / $this->redrawFreq);
  $this->step = $step;
  $this->percent = $this->max ? (double) $this->step / $this->max : 0;
  if ($prevPeriod !== $currPeriod || $this->max === $step) {
    $this
      ->display();
  }
}