Passed
Push — master ( 4017d9...9757db )
by Dev
10:15
created

StaticCommand::execute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 2
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PiedWeb\CMSBundle\Extension\StaticGenerator;
4
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
class StaticCommand extends Command
11
{
12
    private $staticAppGenerator;
13
14
    public function __construct(StaticAppGenerator $staticAppGenerator)
15
    {
16
        parent::__construct();
17
        $this->staticAppGenerator = $staticAppGenerator;
18
    }
19
20
    protected function configure()
21
    {
22
        $this
23
            ->setName('static:generate')
24
            ->setDescription('Generate static version  for your website')
25
            ->addArgument('host', InputArgument::OPTIONAL);
26
    }
27
28
    protected function execute(InputInterface $input, OutputInterface $output)
29
    {
30
        if ($input->getArgument('host')) {
31
            $this->staticAppGenerator->generateFromHost($input->getArgument('host'));
32
        } else {
33
            $this->staticAppGenerator->generateAll();
34
        }
35
36
        $output->writeln('Static version generation succeeded.');
37
38
        return 0;
39
    }
40
}
41