Completed
Push — master ( b77c5c...4fbeac )
by Jeroen
10s
created

SimulateCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 13.89 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 88.89%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 5
loc 36
ccs 8
cts 9
cp 0.8889
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 11 1
A execute() 5 21 3

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
/*
4
 * This file is part of the Conveyor package.
5
 *
6
 * (c) Jeroen Fiege <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Webcreate\Conveyor\Command;
13
14
use Symfony\Component\Console\Input\InputArgument;
15
use Symfony\Component\Console\Input\InputInterface;
16
use Symfony\Component\Console\Input\InputOption;
17
use Symfony\Component\Console\Output\OutputInterface;
18
19
class SimulateCommand extends AbstractCommand
20
{
21 2
    protected function configure()
22
    {
23
        $this
24 2
            ->setName('simulate')
25 2
            ->setDescription('Simulate a deploy')
26 2
            ->addArgument('target', InputArgument::REQUIRED, 'Target or group to simulate')
27 2
            ->addArgument('version', InputArgument::REQUIRED, 'Version to simulate')
28 2
            ->addOption('force', '-f', InputOption::VALUE_NONE, 'Force deploy')
29 2
            ->addOption('full', null, InputOption::VALUE_NONE, 'Full deploy instead of incremental deploy')
30
        ;
31 2
    }
32
33
    protected function execute(InputInterface $input, OutputInterface $output)
34
    {
35
        $conveyor = $this->getConveyor($input, $output, $this->getHelperSet());
36
37
        $options = array();
38
        $options['full_deploy'] = (bool) $input->getOption('full');
39
        $options['force'] = (bool) $input->getOption('force');
40
41
        $target = $input->getArgument('target');
42
        $targets = [$target];
43
44 View Code Duplication
        if (false !== strpos($target, ',')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
45
            $output->writeln('<info>Deprecated: Comma-separated list of targets is no longer supported, please use target groups to deploy to multiple targets at once.</info>');
46
47
            $targets = explode(',', $target);
48
        }
49
50
        foreach ($targets as $target) {
51
            $conveyor->simulate($target, $input->getArgument('version'), $options);
52
        }
53
    }
54
}
55