Completed
Push — master ( aa9657...bb9832 )
by Sebastian
05:21
created

Configuration   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 37.5 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 15
loc 40
c 0
b 0
f 0
ccs 22
cts 22
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 15 15 1
A execute() 0 11 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
 * This file is part of CaptainHook.
4
 *
5
 * (c) Sebastian Feldmann <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace SebastianFeldmann\CaptainHook\Console\Command;
11
12
use SebastianFeldmann\CaptainHook\Runner\Configurator;
13
use SebastianFeldmann\Git\Repository;
14
use Symfony\Component\Console\Input\InputInterface;
15
use Symfony\Component\Console\Input\InputOption;
16
use Symfony\Component\Console\Output\OutputInterface;
17
18
/**
19
 * Class Config
20
 *
21
 * @package CaptainHook
22
 * @author  Sebastian Feldmann <[email protected]>
23
 * @link    https://github.com/sebastianfeldmann/captainhook
24
 * @since   Class available since Release 0.9.0
25
 */
26
class Configuration extends Base
27
{
28
    /**
29
     * Configure the command.
30
     */
31 3 View Code Duplication
    protected function configure()
32
    {
33 3
        $this->setName('configure')
34 3
             ->setDescription('Configure your hooks')
35 3
             ->setHelp('This command creates or updates your captainhook configuration')
36 3
             ->addOption('extend', 'e', InputOption::VALUE_NONE, 'Extend existing configuration file')
37 3
             ->addOption('force', 'f', InputOption::VALUE_NONE, 'Overwrite existing configuration file')
38 3
             ->addOption(
39 3
                 'configuration',
40 3
                 'c',
41 3
                 InputOption::VALUE_OPTIONAL,
42 3
                 'Path to your json configuration',
43 3
                 getcwd() . DIRECTORY_SEPARATOR . 'captainhook.json'
44
             );
45 3
    }
46
47
    /**
48
     * Execute the command.
49
     *
50
     * @param  \Symfony\Component\Console\Input\InputInterface   $input
51
     * @param  \Symfony\Component\Console\Output\OutputInterface $output
52
     * @return void
53
     */
54 2
    protected function execute(InputInterface $input, OutputInterface $output)
55
    {
56 2
        $io     = $this->getIO($input, $output);
57 2
        $config = $this->getConfig($input->getOption('configuration'));
58 2
        $repo   = new Repository();
59
60 2
        $configurator = new Configurator($io, $config, $repo);
61 2
        $configurator->force($input->getOption('force'))
62 2
                     ->extend($input->getOption('extend'))
63 2
                     ->run();
64 2
    }
65
}
66