Passed
Push — master ( c39866...317dcf )
by Marius
04:47
created

SetUpWorkspaceCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 4

Test Coverage

Coverage 60.71%

Importance

Changes 0
Metric Value
wmc 4
lcom 2
cbo 4
dl 0
loc 48
ccs 17
cts 28
cp 0.6071
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A configure() 0 18 1
A execute() 0 17 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Paysera\PhpStormHelper\Command;
5
6
use Paysera\PhpStormHelper\Service\WorkspaceConfigurationHelper;
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\Input\InputOption;
11
use Symfony\Component\Console\Output\OutputInterface;
12
13
class SetUpWorkspaceCommand extends Command
14
{
15
    private $workspaceConfigurationHelper;
16
17 8
    public function __construct(WorkspaceConfigurationHelper $workspaceConfigurationHelper)
18
    {
19 8
        parent::__construct();
20
21 8
        $this->workspaceConfigurationHelper = $workspaceConfigurationHelper;
22 8
    }
23
24 8
    protected function configure()
25
    {
26
        $this
27 8
            ->setName('set-up-workspace')
28 8
            ->addArgument(
29 8
                'project-root-dir',
30 8
                InputArgument::OPTIONAL,
31 8
                'Project root directory in host machine. Default is current directory'
32
            )
33 8
            ->addOption(
34 8
                'composer-executable',
35 8
                null,
36 8
                InputOption::VALUE_OPTIONAL,
37 8
                'Composer executable',
38 8
                'composer'
39
            )
40
        ;
41 8
    }
42
43
    protected function execute(InputInterface $input, OutputInterface $output)
44
    {
45
        $target = $input->getArgument('project-root-dir');
46
        if ($target === null) {
47
            $target = realpath('.');
48
        }
49
50
        $target .= '/.idea/workspace.xml';
51
52
        $composerExecutable = $input->getOption('composer-executable');
53
54
        $this->workspaceConfigurationHelper->configureComposer($target, $composerExecutable);
55
        $this->workspaceConfigurationHelper->configureFileTemplateScheme($target);
56
        $this->workspaceConfigurationHelper->setupPhpUnitRunConfiguration($target);
57
58
        $output->writeln('Restart PhpStorm instance for changes to take effect');
59
    }
60
}
61