NewCommand::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 2
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace PressCLI\Command;
3
4
use PressCLI\Lib\FileSystem;
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Input\ArrayInput;
7
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
class NewCommand extends Command
12
{
13
    use FileSystem;
14
15
    /**
16
     * Configure create command.
17
     */
18
    protected function configure()
19
    {
20
        $this->setName('new')
21
             ->setDescription('Creates a new project directory, configuration and runs the install.')
22
             ->addArgument('project-name', InputArgument::REQUIRED, 'The project name.');
23
    }
24
25
    /**
26
     * Execute create command.
27
     *
28
     * @param  InputInterface  $input
29
     * @param  OutputInterface $output
30
     */
31
    protected function execute(InputInterface $input, OutputInterface $output)
32
    {
33
        // Configure the install.
34
        $name = $input->getArgument('project-name');
35
        $configure = $this->getApplication()->find('configure');
36
        $configure->run(new ArrayInput(['project-name' => $name]), $output);
37
38
        // Go into the newly configured install.
39
        chdir($name);
40
        $output->writeln('');
41
42
        $install = $this->getApplication()->find('install');
43
        $install->run(new ArrayInput([]), $output);
44
    }
45
}
46