Completed
Push — master ( c658e2...e56257 )
by Marius
05:39
created

ConfigureWorkspaceCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
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 ConfigureWorkspaceCommand 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('configure-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
57
        $output->writeln('Restart PhpStorm instance for changes to take effect');
58
    }
59
}
60