Completed
Pull Request — master (#104)
by Damian
05:59 queued 01:40
created

BuildCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 7
Ratio 100 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 7
loc 7
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace Dock\Cli;
4
5
use Dock\Docker\Compose\Project;
6
use Dock\Project\ProjectBuildManager;
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Input\InputArgument;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12 View Code Duplication
class BuildCommand extends Command
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
{
14
    /**
15
     * @var ProjectBuildManager
16
     */
17
    private $projectBuildManager;
18
19
    /**
20
     * @var Project
21
     */
22
    private $project;
23
24
    /**
25
     * @param ProjectBuildManager $projectManager
0 ignored issues
show
Documentation introduced by
There is no parameter named $projectManager. Did you maybe mean $project?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
26
     * @param Project $project
27
     */
28
    public function __construct(ProjectBuildManager $projectBuildManager, Project $project)
29
    {
30
        parent::__construct();
31
32
        $this->projectBuildManager = $projectBuildManager;
33
        $this->project = $project;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    protected function configure()
40
    {
41
        $this
42
            ->setName('build')
43
            ->setDescription('Build and Reset the containers of the project')
44
            ->addArgument('container', InputArgument::IS_ARRAY, 'Component names');
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    protected function execute(InputInterface $input, OutputInterface $output)
51
    {
52
        $containers = $input->getArgument('container');
53
        $this->projectBuildManager->build($this->project, $containers);
54
55
        $output->writeln([
56
            'Container(s) built and successfully reset.',
57
        ]);
58
    }
59
}
60