VolumeCreateCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
eloc 14
dl 0
loc 33
ccs 0
cts 21
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 16 3
1
<?php
2
3
4
namespace Nexus\DockerClient\Communication\Command\Volume;
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 VolumeCreateCommand extends AbstractCommand
16
{
17
    protected function configure(): void
18
    {
19
        $this
20
            ->setName('docker:volume:create')
21
            ->setDescription('Create a docker volume')
22
            ->addArgument('names', InputArgument::IS_ARRAY, 'Volume names seperated by space')
23
        ;
24
    }
25
26
    /**
27
     * @param \Symfony\Component\Console\Input\InputInterface $input
28
     * @param \Symfony\Component\Console\Output\OutputInterface $output
29
     *
30
     * @return int|null|void
31
     */
32
    protected function execute(InputInterface $input, OutputInterface $output)
33
    {
34
        $names = (array)$input->getArgument('names');
35
36
        $response = '';
37
        foreach ($names as $name) {
38
            $command = sprintf(
39
                'volume create %s',
40
                $name
41
            );
42
43
            $response .= $this->getFacade()->runDocker($command);
44
        }
45
46
        if ($output->isVerbose()) {
47
            $output->writeln($response);
48
        }
49
    }
50
51
52
}