| Total Complexity | 7 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | class Planner |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * @var Table |
||
| 22 | */ |
||
| 23 | private $table; |
||
| 24 | /** |
||
| 25 | * @var array |
||
| 26 | */ |
||
| 27 | private $template; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Planner constructor. |
||
| 31 | * |
||
| 32 | * @param Host[] $hosts |
||
| 33 | */ |
||
| 34 | public function __construct(OutputInterface $output, array $hosts) |
||
| 35 | { |
||
| 36 | $headers = []; |
||
| 37 | $this->template = []; |
||
| 38 | foreach ($hosts as $host) { |
||
| 39 | $headers[] = $host->getTag(); |
||
| 40 | $this->template[] = $host->getAlias(); |
||
| 41 | } |
||
| 42 | $this->table = new Table($output); |
||
| 43 | $this->table->setHeaders($headers); |
||
| 44 | $this->table->setStyle('box'); |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @param Host[] $hosts |
||
| 49 | */ |
||
| 50 | public function commit(array $hosts, Task $task): void |
||
| 51 | { |
||
| 52 | $row = []; |
||
| 53 | foreach ($this->template as $alias) { |
||
| 54 | $on = "-"; |
||
| 55 | foreach ($hosts as $host) { |
||
| 56 | if ($alias === $host->getAlias()) { |
||
| 57 | $on = $task->getName(); |
||
| 58 | break; |
||
| 59 | } |
||
| 60 | } |
||
| 61 | $row[] = $on; |
||
| 62 | } |
||
| 63 | $this->table->addRow($row); |
||
| 64 | } |
||
| 65 | |||
| 66 | public function render() |
||
| 69 | } |
||
| 70 | } |
||
| 71 |