| Conditions | 4 |
| Paths | 4 |
| Total Lines | 25 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | private function getRunningDockerContainers(): array |
||
| 22 | { |
||
| 23 | $runner = new Runner(); |
||
| 24 | |||
| 25 | if (!$runner->commandExists('docker')) return []; |
||
| 26 | |||
| 27 | $cmd = 'docker ps --format {{.ID}}|{{.Image}}|{{.Names}}|{{.Ports}}'; |
||
| 28 | $output = Runner::getInstance()->run($cmd)->getOutput(); |
||
| 29 | |||
| 30 | $lines = explode("\n", trim($output)); |
||
| 31 | $containers = []; |
||
| 32 | |||
| 33 | foreach ($lines as $line) { |
||
| 34 | if (empty($line)) continue; |
||
| 35 | |||
| 36 | [$id, $image, $name, $ports] = explode('|', $line); |
||
| 37 | $containers[] = [ |
||
| 38 | 'id' => $id, |
||
| 39 | 'image' => $image, |
||
| 40 | 'name' => $name, |
||
| 41 | 'ports' => $ports, |
||
| 42 | ]; |
||
| 43 | } |
||
| 44 | |||
| 45 | return $containers; |
||
| 46 | } |
||
| 57 |