Test Failed
Push — master ( 7ebbda...77d842 )
by Mike
02:15
created

DockerBuildCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 13
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 0 12 2
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\Command\AbstractCommand;
11
12
/**
13
 * @method \Nexus\DockerClient\DockerClientFacade getFacade()
14
 */
15
class DockerBuildCommand extends AbstractCommand
16
{
17
    protected function configure()
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
     * @throws \Core\Locator\Dynamic\ServiceNotParseable
32
     */
33
    protected function execute(InputInterface $input, OutputInterface $output)
34
    {
35
        $command = sprintf(
36
            'build %s -t %s',
37
            $input->getArgument('directory'),
38
            $input->getArgument('image')
39
        );
40
41
        $response = $this->getFacade()->runDocker($command);
42
43
        if ($output->isVerbose()) {
44
            $output->writeln($response);
45
        }
46
    }
47
48
49
}