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

DeployCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 12.82 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 90%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 12 1
A execute() 5 23 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 DeployCommand extends AbstractCommand
20
{
21 2
    protected function configure()
22
    {
23
        $this
24 2
            ->setName('deploy')
25 2
            ->setDescription('Deploy')
26 2
            ->addArgument('target', InputArgument::REQUIRED, 'Target or group to deploy')
27 2
            ->addArgument('version', InputArgument::REQUIRED, 'Version to deploy')
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 2
            ->addOption('after', null, InputOption::VALUE_NONE, 'Only run deploy after tasks')
31
        ;
32 2
    }
33
34
    protected function execute(InputInterface $input, OutputInterface $output)
35
    {
36
        $conveyor = $this->getConveyor($input, $output, $this->getHelperSet());
37
38
        $options = array();
39
40
        $options['full_deploy'] = (bool) $input->getOption('full');
41
        $options['deploy_after_only'] = (bool) $input->getOption('after');
42
        $options['force'] = (bool) $input->getOption('force');
43
44
        $target = $input->getArgument('target');
45
        $targets = [$target];
46
47 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...
48
            $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>');
49
50
            $targets = explode(',', $target);
51
        }
52
53
        foreach ($targets as $target) {
54
            $conveyor->deploy($target, $input->getArgument('version'), $options);
55
        }
56
    }
57
}
58