3 namespace Robo\Collection;
5 use Robo\Contract\TaskInterface;
6 use Robo\Contract\WrappedTaskInterface;
7 use Robo\Contract\ProgressIndicatorAwareInterface;
10 * One element in a collection. Each element consists of a task
11 * all of its before tasks, and all of its after tasks.
13 * This class is internal to Collection; it should not be used directly.
18 * @var \Robo\Contract\TaskInterface
25 protected $before = [];
30 protected $after = [];
32 public function __construct(TaskInterface $task)
38 * @param mixed $before
41 public function before($before, $name)
44 $this->before[$name] = $before;
46 $this->before[] = $before;
54 public function after($after, $name)
57 $this->after[$name] = $after;
59 $this->after[] = $after;
66 public function getBefore()
74 public function getAfter()
80 * @return \Robo\Contract\TaskInterface
82 public function getTask()
90 public function getTaskList()
92 return array_merge($this->getBefore(), [$this->getTask()], $this->getAfter());
98 public function progressIndicatorSteps()
101 foreach ($this->getTaskList() as $task) {
102 if ($task instanceof WrappedTaskInterface) {
103 $task = $task->original();
105 // If the task is a ProgressIndicatorAwareInterface, then it
106 // will advance the progress indicator a number of times.
107 if ($task instanceof ProgressIndicatorAwareInterface) {
108 $steps += $task->progressIndicatorSteps();
110 // We also advance the progress indicator once regardless
111 // of whether it is progress-indicator aware or not.