private function ProgressHelper::generate in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/console/Helper/ProgressHelper.php \Symfony\Component\Console\Helper\ProgressHelper::generate()
Generates the array map of format variables to values.
Parameters
bool $finish Forces the end result:
Return value
array Array of format vars and values
1 call to ProgressHelper::generate()
- ProgressHelper::display in vendor/
symfony/ console/ Helper/ ProgressHelper.php - Outputs the current progress string.
File
- vendor/
symfony/ console/ Helper/ ProgressHelper.php, line 360
Class
- ProgressHelper
- The Progress class provides helpers to display progress output.
Namespace
Symfony\Component\Console\HelperCode
private function generate($finish = false) {
$vars = array();
$percent = 0;
if ($this->max > 0) {
$percent = (double) $this->current / $this->max;
}
if (isset($this->formatVars['bar'])) {
$completeBars = 0;
if ($this->max > 0) {
$completeBars = floor($percent * $this->barWidth);
}
else {
if (!$finish) {
$completeBars = floor($this->current % $this->barWidth);
}
else {
$completeBars = $this->barWidth;
}
}
$emptyBars = $this->barWidth - $completeBars - $this
->strlen($this->progressChar);
$bar = str_repeat($this->barChar, $completeBars);
if ($completeBars < $this->barWidth) {
$bar .= $this->progressChar;
$bar .= str_repeat($this->emptyBarChar, $emptyBars);
}
$vars['bar'] = $bar;
}
if (isset($this->formatVars['elapsed'])) {
$elapsed = time() - $this->startTime;
$vars['elapsed'] = str_pad($this
->humaneTime($elapsed), $this->widths['elapsed'], ' ', STR_PAD_LEFT);
}
if (isset($this->formatVars['current'])) {
$vars['current'] = str_pad($this->current, $this->widths['current'], ' ', STR_PAD_LEFT);
}
if (isset($this->formatVars['max'])) {
$vars['max'] = $this->max;
}
if (isset($this->formatVars['percent'])) {
$vars['percent'] = str_pad(floor($percent * 100), $this->widths['percent'], ' ', STR_PAD_LEFT);
}
return $vars;
}