Completed
Pull Request — master (#104)
by Damian
12:02 queued 07:44
created

BuildCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 7
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
1
<?php
2
3
namespace Dock\Cli;
4
5
use Dock\Docker\Compose\Project;
6
use Dock\Project\DockerComposeProjectManager;
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 ProjectManager
16
     */
17
    private $projectManager;
18
19
    /**
20
     * @var Project
21
     */
22
    private $project;
23
24
    /**
25
     * @param DockerComposeProjectManager $projectManager
26
     * @param Project        $project
27
     */
28
    public function __construct(DockerComposeProjectManager $projectManager, Project $project)
29
    {
30
        parent::__construct();
31
32
        $this->projectManager = $projectManager;
0 ignored issues
show
Documentation Bug introduced by
It seems like $projectManager of type object<Dock\Project\DockerComposeProjectManager> is incompatible with the declared type object<Dock\Cli\ProjectManager> of property $projectManager.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
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
    /**
49
     * {@inheritdoc}
50
     */
51
    protected function execute(InputInterface $input, OutputInterface $output)
52
    {
53
        $containers = $input->getArgument('container');
54
        $this->projectManager->build($this->project, $containers);
55
56
        $output->writeln([
57
            'Container(s) built and successfully reset.',
58
        ]);
59
    }
60
}
61