| Conditions | 9 |
| Paths | 19 |
| Total Lines | 36 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 20 |
| CRAP Score | 9.0608 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php namespace Mistletoe\Runners; |
||
| 20 | 1 | protected function executeTasks(array $tasks) |
|
| 21 | { |
||
| 22 | 1 | if ($this->testing) { |
|
| 23 | return $tasks; |
||
| 24 | } |
||
| 25 | |||
| 26 | 1 | $processes = []; |
|
| 27 | |||
| 28 | /** @var TaskBag $task */ |
||
| 29 | 1 | foreach ($tasks as $task) { |
|
| 30 | 1 | $processes[] = $task->getTask(); |
|
| 31 | 1 | $processes = array_merge($processes, $task->getFollowedBy()); |
|
| 32 | 1 | } |
|
| 33 | |||
| 34 | 1 | foreach ($processes as $process) { |
|
| 35 | // Create a Process instance |
||
| 36 | 1 | if (is_string($process) && class_exists($process)) { |
|
| 37 | 1 | $process = new $process(); |
|
| 38 | 1 | } |
|
| 39 | |||
| 40 | // Try to Run that Process |
||
| 41 | 1 | if (is_callable($process)) { |
|
| 42 | $process(); |
||
| 43 | |||
| 44 | 1 | } elseif ($process instanceof Command) { |
|
| 45 | 1 | exec($process->getCommand()); |
|
| 46 | |||
| 47 | 1 | } elseif ($process instanceof RunnableInterface) { |
|
| 48 | /** @var \Mistletoe\Contracts\RunnableInterface $obj */ |
||
| 49 | 1 | $obj = new $process(); |
|
| 50 | 1 | $obj->run(); |
|
| 51 | 1 | } |
|
| 52 | 1 | } |
|
| 53 | |||
| 54 | 1 | return true; |
|
| 55 | } |
||
| 56 | } |
||
| 57 |