Test Failed
Branch new-architecture (b1743d)
by James
03:04
created

GenerateCommand::execute()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 19
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 13
Bugs 1 Features 1
Metric Value
c 13
b 1
f 1
dl 0
loc 19
rs 9.4285
cc 3
eloc 12
nc 3
nop 2
1
<?php
2
3
/**
4
 * This file is, guess what, part of WebHelper.
5
 *
6
 * (c) James <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace JamesRezo\WebHelper\Command;
13
14
use Symfony\Component\Console\Command\Command;
15
use Symfony\Component\Console\Input\InputInterface;
16
use Symfony\Component\Console\Output\OutputInterface;
17
use JamesRezo\WebHelper\WebHelper;
18
19
class GenerateCommand extends Command
20
{
21
    protected function configure()
22
    {
23
        $this
24
            ->setName('generate')
25
            ->setDescription('Output statements for a webserver')
26
            ->setHelp('The <info>generate</info> command creates one or many statements for the specified webserver.')
27
        ;
28
    }
29
30
    protected function execute(InputInterface $input, OutputInterface $output)
31
    {
32
        $input = $input;
0 ignored issues
show
Bug introduced by
Why assign $input to itself?

This checks looks for cases where a variable has been assigned to itself.

This assignement can be removed without consequences.

Loading history...
33
        $webhelper = new WebHelper();
34
        $webhelper->setRepository(__DIR__ . '/../../res');
35
36
        if ($webhelper->getRepository()->okGo()) {
37
            $webhelper->setServer('apache', '2.4.18');
38
            foreach (['alias', 'directory'] as $directive) {
39
                $twigFile = $webhelper->find($directive);
40
                $output->write($webhelper->render($twigFile, [
41
                    'project' => [
42
                        'aliasname' => 'webhelper',
43
                        'documentroot' => realpath(__DIR__ . '/../../')
44
                    ]
45
                ]));
46
            }
47
        }
48
    }
49
}
50