Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adds methods in Progress to return the current value and total … #206

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}
}