BuildCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 100 %

Coupling/Cohesion

Components 2
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 2
cbo 4
dl 48
loc 48
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 7 7 1
A configure() 7 7 1
A execute() 9 9 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 $projectBuildManager
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