Skip to content

Commit

Permalink
feat: Adds methods in Progress to return the current value and total …
Browse files Browse the repository at this point in the history
…value of the progress bar.

This commit adds methods in Progress to return the current value and total value of the progress bar.

Issue #192
  • Loading branch information
everton3x committed Oct 30, 2024
1 parent 2bb5ad2 commit 32d643b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/TerminalObject/Dynamic/Progress.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,4 +338,24 @@ protected function shouldRedraw($percentage, $label)
{
return ($this->force_redraw || $percentage != $this->current_percentage || $label != $this->label);
}

/**
* Gets de current progress value.
*
* @return integer The current progress value.
*/
public function getCurrent()
{
return $this->current;
}

/**
* Gets the total value for the progress.
*
* @return integer The total progress value.
*/
public function getTotal()
{
return $this->total;
}
}
10 changes: 10 additions & 0 deletions tests/TerminalObject/Dynamic/ProgressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,4 +402,14 @@ public function testEach4()
return $item;
});
}

public function testGetCurrent()
{
$this->assertEquals(0, $this->cli->progress(100)->getCurrent());
}

public function testGetTotal()
{
$this->assertEquals(100, $this->cli->progress(100)->getTotal());
}
}

0 comments on commit 32d643b

Please sign in to comment.