NewCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 5
dl 0
loc 35
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 6 1
A execute() 0 14 1
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