DockerComposeRmCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 11
dl 0
loc 26
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 6 1
A execute() 0 10 2
1
<?php
2
3
4
namespace Nexus\DockerClient\Communication\Command\Compose;
5
6
7
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
use Xervice\Console\Business\Model\Command\AbstractCommand;
11
12
/**
13
 * @method \Nexus\DockerClient\Business\DockerClientFacade getFacade()
14
 */
15
class DockerComposeRmCommand extends AbstractCommand
16
{
17
    protected function configure(): void
18
    {
19
        $this
20
            ->setName('docker:compose:rm')
21
            ->setDescription('Docker composer rm')
22
            ->addArgument('files', InputArgument::IS_ARRAY, 'Compose file', ['docker-compose.yaml']);
23
    }
24
25
    /**
26
     * @param \Symfony\Component\Console\Input\InputInterface $input
27
     * @param \Symfony\Component\Console\Output\OutputInterface $output
28
     *
29
     * @return int|null|void
30
     */
31
    protected function execute(InputInterface $input, OutputInterface $output)
32
    {
33
        $files = $input->getArgument('files');
34
        $fileSuffix = ' -f ' . implode(' -f ', $files);
35
36
        $command = sprintf('%s rm -fsv', $fileSuffix);
37
        $response = $this->getFacade()->runDockerCompose($command);
38
39
        if ($output->isVerbose()) {
40
            $output->writeln($response);
41
        }
42
    }
43
44
45
}