Permalink
Browse files

[Console] added a note in the CHANGELOG for the previous merge, fixed…

… some CS
  • Loading branch information...
1 parent b95995f commit ce8d34ee8b1abc7c0f3d0923fdb32a85e7decb98 @fabpot fabpot committed Mar 23, 2013
Showing with 18 additions and 12 deletions.
  1. +5 −0 CHANGELOG.md
  2. +13 −12 Helper/ProgressHelper.php
View
@@ -1,6 +1,11 @@
CHANGELOG
=========
+2.3.0
+-----
+
+ * added a way to set the progress bar progress via the `setCurrent` method
+
2.2.0
-----
View
@@ -91,10 +91,10 @@ class ProgressHelper extends Helper
* @var array
*/
private $widths = array(
- 'current' => 4,
- 'max' => 4,
- 'percent' => 3,
- 'elapsed' => 6,
+ 'current' => 4,
+ 'max' => 4,
+ 'percent' => 3,
+ 'elapsed' => 6,
);
/**
@@ -227,11 +227,12 @@ public function advance($step = 1, $redraw = false)
throw new \LogicException('You must start the progress bar before calling advance().');
}
- if ($this->current === 0) {
+ if (0 === $this->current) {
$redraw = true;
}
+
$this->current += $step;
- if ($redraw || $this->current % $this->redrawFreq === 0) {
+ if ($redraw || 0 === $this->current % $this->redrawFreq) {
$this->display();
}
}
@@ -256,12 +257,12 @@ public function setCurrent($current, $redraw = false)
throw new \LogicException('You can\'t regress the progress bar');
}
- if ($this->current === 0) {
+ if (0 === $this->current) {
$redraw = true;
}
$this->current = $current;
- if ($redraw || $this->current % $this->redrawFreq === 0) {
+ if ($redraw || 0 === $this->current % $this->redrawFreq) {
$this->display();
}
}
@@ -295,7 +296,7 @@ public function finish()
throw new \LogicException('You must start the progress bar before calling finish().');
}
- if ($this->startTime !== null) {
+ if (null !== $this->startTime) {
if (!$this->max) {
$this->barChar = $this->barCharOriginal;
$this->display(true);
@@ -313,7 +314,7 @@ private function initialize()
{
$this->formatVars = array();
foreach ($this->defaultFormatVars as $var) {
- if (strpos($this->format, "%{$var}%") !== false) {
+ if (false !== strpos($this->format, "%{$var}%")) {
$this->formatVars[$var] = true;
}
}
@@ -344,7 +345,7 @@ private function generate($finish = false)
if (isset($this->formatVars['bar'])) {
$completeBars = 0;
- $emptyBars = 0;
+ $emptyBars = 0;
if ($this->max > 0) {
$completeBars = floor($percent * $this->barWidth);
} else {
@@ -421,7 +422,7 @@ private function overwrite(OutputInterface $output, $message)
$length = $this->getLength($message);
// append whitespace to match the last line's length
- if (($this->lastMessagesLength !== null) && ($this->lastMessagesLength > $length)) {
+ if (null !== $this->lastMessagesLength && $this->lastMessagesLength > $length) {
$message = str_pad($message, $this->lastMessagesLength, "\x20", STR_PAD_RIGHT);
}

0 comments on commit ce8d34e

Please sign in to comment.