Completed
Pull Request — master (#34)
by
unknown
02:30
created

BuildCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
dl 0
loc 44
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
B execute() 0 27 3
1
<?php
2
3
namespace allejo\stakx\Command;
4
5
use Symfony\Component\Console\Input\InputInterface;
6
use Symfony\Component\Console\Output\OutputInterface;
7
use allejo\stakx\Exception\InvalidSyntaxException;
8
9
class BuildCommand extends BuildableCommand
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    protected function configure ()
15
    {
16
        parent::configure();
17
18
        $this->setName('build');
19
        $this->setDescription('Builds the stakx website');
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    protected function execute (InputInterface $input, OutputInterface $output)
26
    {
27
        parent::execute($input, $output);
28
29
        try
30
        {
31
            $this->configureBuild($input);
32
            $this->website->build();
33
34
            $output->writeln(sprintf("Your site built successfully! It can be found at: %s",
35
                $this->website->getConfiguration()->getTargetFolder() . DIRECTORY_SEPARATOR
36
            ));
37
        }
38
        catch (InvalidSyntaxException $e)
39
        {
40
            $output->writeln(sprintf("Your website failed to build with the following error in file '%s': %s",
41
                $e->getPath(),
42
                $e->getMessage()
43
            ));
44
        }
45
        catch (\Exception $e)
46
        {
47
            $output->writeln(sprintf("Your website failed to build with the following error: %s",
48
                $e->getMessage()
49
            ));
50
        }
51
    }
52
}