Completed
Pull Request — master (#6)
by coExp
02:24
created
src/ProgressBar.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function __construct(OutputInterface $output)
47 47
     {
48
-        $output->getFormatter()->setStyle('ok',  new OutputFormatterStyle('black', 'green', ['bold']));
48
+        $output->getFormatter()->setStyle('ok', new OutputFormatterStyle('black', 'green', ['bold']));
49 49
         $output->getFormatter()->setStyle('err', new OutputFormatterStyle('red', 'black', ['bold']));
50 50
 
51 51
         if ($output instanceof ConsoleOutputInterface) {
@@ -189,25 +189,25 @@  discard block
 block discarded – undo
189 189
 
190 190
             $percent = $this->getNbrDone() / $this->length;
191 191
 
192
-            $lengthPassed   = (int) ($percentPassed  * self::PROGRESSION_LENGTH);
192
+            $lengthPassed   = (int) ($percentPassed * self::PROGRESSION_LENGTH);
193 193
             $lengthWarning  = (int) ($percentWarning * self::PROGRESSION_LENGTH);
194
-            $lengthDone     = (int) ($percentDone    * self::PROGRESSION_LENGTH);
195
-            $lengthError    = (int) ($percentError   * self::PROGRESSION_LENGTH);
194
+            $lengthDone     = (int) ($percentDone * self::PROGRESSION_LENGTH);
195
+            $lengthError    = (int) ($percentError * self::PROGRESSION_LENGTH);
196 196
 
197 197
             $lengthLeft = self::PROGRESSION_LENGTH - $lengthPassed - $lengthDone - $lengthError - $lengthWarning;
198
-            $lengthLeft = ($lengthLeft < 0 ) ? 0 : $lengthLeft;
198
+            $lengthLeft = ($lengthLeft < 0) ? 0 : $lengthLeft;
199 199
 
200
-            $msg  = "\r" . sprintf('%3d', round($percent*100, 0)) . "%: [";
200
+            $msg  = "\r" . sprintf('%3d', round($percent * 100, 0)) . "%: [";
201 201
 
202
-            $msg .= '<info>'    . str_repeat('#', $lengthDone)   . '</info>';
202
+            $msg .= '<info>' . str_repeat('#', $lengthDone) . '</info>';
203 203
             $msg .= '<comment>' . str_repeat('#', $lengthPassed) . '</comment>';
204
-            $msg .= '<err>'   . str_repeat('#', $lengthError)  . '</err>';
204
+            $msg .= '<err>' . str_repeat('#', $lengthError) . '</err>';
205 205
 
206 206
             $msg .= str_repeat('-', $lengthLeft) . '] ';
207
-            $msg .= ($this->nbrSuccess)    ? " Done:<info>$this->nbrSuccess</info>" : '';
207
+            $msg .= ($this->nbrSuccess) ? " Done:<info>$this->nbrSuccess</info>" : '';
208 208
             $msg .= ($this->nbrWarning) ? " Warn:<comment>$this->nbrWarning</comment>" : '';
209
-            $msg .= ($this->nbrPassed)  ? " Pass:$this->nbrPassed" : '';
210
-            $msg .= ($this->nbrError)   ? " Err:<err>$this->nbrError</err>" : '';
209
+            $msg .= ($this->nbrPassed) ? " Pass:$this->nbrPassed" : '';
210
+            $msg .= ($this->nbrError) ? " Err:<err>$this->nbrError</err>" : '';
211 211
             $msg .= ' Remaining:' . ($nbrRemaining);
212 212
 
213 213
             $msg .= ' Elapsed:<info>' . $this->formatTime($timeElapsed) . '</info>';
Please login to merge, or discard this patch.
src/MultipleBar.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         }
161 161
 
162 162
         for ($i = 0 ; $i < $number ; $i++) {
163
-           $this->progressBars[] = new ProgressBar($this->getOutput());
163
+            $this->progressBars[] = new ProgressBar($this->getOutput());
164 164
         }
165 165
 
166 166
         return $this;
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
     public function addProgressBarByName(array $names)
174 174
     {
175 175
         foreach ($names as $name) {
176
-           $this->progressBars[$name] = new ProgressBar($this->getOutput());
176
+            $this->progressBars[$name] = new ProgressBar($this->getOutput());
177 177
         }
178 178
 
179 179
         return $this;
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
      */
85 85
     public function erase()
86 86
     {
87
-        for ($i = 0 ; $i < $this->length; $i++) {
88
-            $this->originalOutput->write(self::CLEAR_LINE.self::MOVE_CURSOR_UP);
87
+        for ($i = 0; $i < $this->length; $i++) {
88
+            $this->originalOutput->write(self::CLEAR_LINE . self::MOVE_CURSOR_UP);
89 89
         }
90 90
 
91 91
         $this->length = 0;
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         $this->erase();
102 102
 
103 103
         if (false === empty($this->title)) {
104
-            $this->originalOutput->writeln(self::CLEAR_LINE.$this->title);
104
+            $this->originalOutput->writeln(self::CLEAR_LINE . $this->title);
105 105
             $this->length++;
106 106
         }
107 107
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
             throw new MultipleBarConfigurationException('Illegal number of ProgressBar');
160 160
         }
161 161
 
162
-        for ($i = 0 ; $i < $number ; $i++) {
162
+        for ($i = 0; $i < $number; $i++) {
163 163
            $this->progressBars[] = new ProgressBar($this->getOutput());
164 164
         }
165 165
 
Please login to merge, or discard this patch.
tests/MultipleBarTest.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     public function test_one_line()
44 44
     {
45 45
         $mb = (new MultipleBar($this->output))
46
-            ->setTitle(__METHOD__.': '.(new DateTime())->format(DATE_ATOM))
46
+            ->setTitle(__METHOD__ . ': ' . (new DateTime())->format(DATE_ATOM))
47 47
             ->addProgressBar();
48 48
 
49 49
         $mb->getProgressBarByIndex(0)
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
         $this->assertInstanceOf(ProgressBar::class, $mb->getProgressBarByIndex(0));
53 53
         $this->assertNull($mb->getProgressBarByIndex(1));
54 54
 
55
-        for ($i = 0 ; $i < 20 ; $i++) {
55
+        for ($i = 0; $i < 20; $i++) {
56 56
             $mb->getProgressBarByIndex(0)->advance();
57 57
             $mb->show();
58 58
             usleep(100000);
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     {
69 69
         $mb = (new MultipleBar($this->output))
70 70
             ->setStdError(true)
71
-            ->setTitle(__METHOD__.': '.(new DateTime())->format(DATE_ATOM))
71
+            ->setTitle(__METHOD__ . ': ' . (new DateTime())->format(DATE_ATOM))
72 72
             ->addProgressBar();
73 73
 
74 74
         $mb->getProgressBarByIndex(0)
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
         $this->assertInstanceOf(ProgressBar::class, $mb->getProgressBarByIndex(0));
78 78
         $this->assertNull($mb->getProgressBarByIndex(1));
79 79
 
80
-        for ($i = 0 ; $i < 20 ; $i++) {
80
+        for ($i = 0; $i < 20; $i++) {
81 81
             $mb->getProgressBarByIndex(0)->advance();
82 82
             $mb->show();
83 83
             usleep(100000);
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     public function test_two_line_unknown_length()
90 90
     {
91 91
         $mb = (new MultipleBar($this->output))
92
-            ->setTitle(__METHOD__.': '.(new DateTime())->format(DATE_ATOM))
92
+            ->setTitle(__METHOD__ . ': ' . (new DateTime())->format(DATE_ATOM))
93 93
             ->addProgressBarByName(['Master']);
94 94
 
95 95
         /** @see https://symfony.com/doc/current/components/console/helpers/progressbar.html#custom-formats */
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         $this->assertInstanceOf(ProgressBar::class, $mb->getProgressBarByName('Master'));
104 104
         $this->assertNull($mb->getProgressBarByName('Child'));
105 105
 
106
-        for ($i = 0 ; $i < 4 ; $i++) {
106
+        for ($i = 0; $i < 4; $i++) {
107 107
             $mb->addProgressBarByName(['Child']);
108 108
 
109 109
             $this->assertInstanceOf(ProgressBar::class, $mb->getProgressBarByName('Child'));
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         $length = [23, 24, 25, 26]; // total = 98
135 135
 
136 136
         $mb = (new MultipleBar($this->output))
137
-            ->setTitle(__METHOD__.': '.(new DateTime())->format(DATE_ATOM))
137
+            ->setTitle(__METHOD__ . ': ' . (new DateTime())->format(DATE_ATOM))
138 138
             ->addProgressBarByName(['Master', 'Child']);
139 139
 
140 140
         /** @see https://symfony.com/doc/current/components/console/helpers/progressbar.html#custom-formats */
Please login to merge, or discard this patch.