| Conditions | 4 |
| Paths | 1 |
| Total Lines | 34 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 33 | public function getTasks($name, $stage = null) |
||
| 34 | { |
||
| 35 | $collect = function ($name) use (&$collect, $stage) { |
||
| 36 | $task = $this->tasks->get($name); |
||
| 37 | if ($stage === null || $task->isForStages($stage)) { |
||
| 38 | if ($task instanceof GroupTask) { |
||
| 39 | return array_map($collect, $task->getTasks()); |
||
| 40 | } else { |
||
| 41 | return array_merge( |
||
| 42 | array_map($collect, $task->getBefore()), |
||
| 43 | [$name], |
||
| 44 | array_map($collect, $task->getAfter()) |
||
| 45 | ); |
||
| 46 | } |
||
| 47 | } else { |
||
| 48 | return []; |
||
| 49 | } |
||
| 50 | }; |
||
| 51 | |||
| 52 | $script = $collect($name); |
||
| 53 | |||
| 54 | // Flatten |
||
| 55 | $tasks = []; |
||
| 56 | array_walk_recursive($script, function ($a) use (&$tasks) { |
||
| 57 | $tasks[] = $a; |
||
| 58 | }); |
||
| 59 | |||
| 60 | // Convert names to real strings. |
||
| 61 | $tasks = array_map(function ($name) { |
||
| 62 | return $this->tasks->get($name); |
||
| 63 | }, $tasks); |
||
| 64 | |||
| 65 | return $tasks; |
||
| 66 | } |
||
| 67 | } |
||
| 68 |