X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fconsolidation%2Frobo%2Fsrc%2FCollection%2FElement.php;fp=vendor%2Fconsolidation%2Frobo%2Fsrc%2FCollection%2FElement.php;h=b67b56bbd087585b247f8a4226c6a68492ba0306;hp=0000000000000000000000000000000000000000;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/vendor/consolidation/robo/src/Collection/Element.php b/vendor/consolidation/robo/src/Collection/Element.php new file mode 100644 index 000000000..b67b56bbd --- /dev/null +++ b/vendor/consolidation/robo/src/Collection/Element.php @@ -0,0 +1,116 @@ +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; + } +}