DockerBuildCommand::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 12
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 6
1
<?php
2
3
4
namespace Nexus\DockerClient\Communication\Command\Build;
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 DockerBuildCommand extends AbstractCommand
16
{
17
    protected function configure(): void
18
    {
19
        $this
20
            ->setName('docker:build')
21
            ->setDescription('Build a docker image')
22
            ->addArgument('directory', InputArgument::REQUIRED, 'Build directory')
23
            ->addArgument('image', InputArgument::REQUIRED, 'Image name');
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
        $command = sprintf(
35
            'build %s -t %s',
36
            $input->getArgument('directory'),
37
            $input->getArgument('image')
38
        );
39
40
        $response = $this->getFacade()->runDocker($command);
41
42
        if ($output->isVerbose()) {
43
            $output->writeln($response);
44
        }
45
    }
46
47
48
}