4 use Robo\Contract\ProgressIndicatorAwareInterface;
5 use Robo\Contract\VerbosityThresholdInterface;
7 trait ProgressIndicatorAwareTrait
12 * @var null|\Robo\Common\ProgressIndicator
14 protected $progressIndicator;
19 public function progressIndicatorSteps()
25 * @param null|\Robo\Common\ProgressIndicator $progressIndicator
27 * @return ProgressIndicatorAwareInterface
29 public function setProgressIndicator($progressIndicator)
31 $this->progressIndicator = $progressIndicator;
39 protected function hideProgressIndicator()
41 if (!$this->progressIndicator) {
44 return $this->progressIndicator->hideProgressIndicator();
47 protected function showProgressIndicator()
49 if (!$this->progressIndicator) {
52 $this->progressIndicator->showProgressIndicator();
56 * @param bool $visible
58 protected function restoreProgressIndicator($visible)
60 if (!$this->progressIndicator) {
63 $this->progressIndicator->restoreProgressIndicator($visible);
69 protected function getTotalExecutionTime()
71 if (!$this->progressIndicator) {
74 return $this->progressIndicator->getExecutionTime();
77 protected function startProgressIndicator()
80 if ($this instanceof VerbosityThresholdInterface
81 && !$this->verbosityMeetsThreshold()) {
84 if (!$this->progressIndicator) {
87 $totalSteps = $this->progressIndicatorSteps();
88 $this->progressIndicator->startProgressIndicator($totalSteps, $this);
94 protected function inProgress()
96 if (!$this->progressIndicator) {
99 return $this->progressIndicator->inProgress();
102 protected function stopProgressIndicator()
105 if (!$this->progressIndicator) {
108 $this->progressIndicator->stopProgressIndicator($this);
111 protected function disableProgressIndicator()
114 if (!$this->progressIndicator) {
117 $this->progressIndicator->disableProgressIndicator();
120 protected function detatchProgressIndicator()
122 $this->setProgressIndicator(null);
128 protected function advanceProgressIndicator($steps = 1)
130 if (!$this->progressIndicator) {
133 $this->progressIndicator->advanceProgressIndicator($steps);