Skip to content

Commit 39d0bf4

Browse files
authored
feat: Adds methods in Progress to return the current value and total value of the progress bar. (#206)
1 parent 2bb5ad2 commit 39d0bf4

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/TerminalObject/Dynamic/Progress.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,4 +338,24 @@ protected function shouldRedraw($percentage, $label)
338338
{
339339
return ($this->force_redraw || $percentage != $this->current_percentage || $label != $this->label);
340340
}
341+
342+
/**
343+
* Gets de current progress value.
344+
*
345+
* @return integer The current progress value.
346+
*/
347+
public function getCurrent()
348+
{
349+
return $this->current;
350+
}
351+
352+
/**
353+
* Gets the total value for the progress.
354+
*
355+
* @return integer The total progress value.
356+
*/
357+
public function getTotal()
358+
{
359+
return $this->total;
360+
}
341361
}

tests/TerminalObject/Dynamic/ProgressTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,4 +402,14 @@ public function testEach4()
402402
return $item;
403403
});
404404
}
405+
406+
public function testGetCurrent()
407+
{
408+
$this->assertEquals(0, $this->cli->progress(100)->getCurrent());
409+
}
410+
411+
public function testGetTotal()
412+
{
413+
$this->assertEquals(100, $this->cli->progress(100)->getTotal());
414+
}
405415
}

0 commit comments

Comments
 (0)