task = $task; } /** * @param mixed $before * @param string $name */ public function before($before, $name) { if ($name) { $this->before[$name] = $before; } else { $this->before[] = $before; } } /** * @param mixed $after * @param string $name */ public function after($after, $name) { if ($name) { $this->after[$name] = $after; } else { $this->after[] = $after; } } /** * @return array */ public function getBefore() { return $this->before; } /** * @return array */ public function getAfter() { return $this->after; } /** * @return \Robo\Contract\TaskInterface */ public function getTask() { return $this->task; } /** * @return array */ public function getTaskList() { return array_merge($this->getBefore(), [$this->getTask()], $this->getAfter()); } /** * @return int */ public function progressIndicatorSteps() { $steps = 0; foreach ($this->getTaskList() as $task) { if ($task instanceof WrappedTaskInterface) { $task = $task->original(); } // If the task is a ProgressIndicatorAwareInterface, then it // will advance the progress indicator a number of times. if ($task instanceof ProgressIndicatorAwareInterface) { $steps += $task->progressIndicatorSteps(); } // We also advance the progress indicator once regardless // of whether it is progress-indicator aware or not. $steps++; } return $steps; } }