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

Configuration::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 11
c 0
b 0
f 0
ccs 9
cts 9
cp 1
rs 9.4285
cc 1
eloc 8
nc 1
nop 2
crap 1
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