Build::execute()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 17
rs 9.4285
cc 3
eloc 9
nc 4
nop 2
1
<?php
2
3
namespace Dmitrynaum\SAM\Command;
4
5
use Dmitrynaum\SAM\AssetBuilder;
6
use Symfony\Component\Console\Command\Command;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Input\InputOption;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
/**
12
 * Команда для сборки (компиляции) asset`ов
13
 *
14
 * @author Naumov Dmitry <[email protected]>
15
 */
16
class Build extends Command
17
{
18
    protected function configure()
19
    {
20
        $this
21
            ->setName('build')
22
            ->setDescription('Build assets')
23
            ->addArgument(
24
                'manifest',
25
                null,
26
                'Path to manifest file.',
27
                './sam.json'
28
            )
29
            ->addOption(
30
                'minify',
31
                'm',
32
                InputOption::VALUE_NONE,
33
                'Minify assets'
34
            )
35
            ->addOption(
36
                'freeze',
37
                'f',
38
                InputOption::VALUE_NONE,
39
                'Freeze assets'
40
            )
41
        ;
42
    }
43
44
    protected function execute(InputInterface $input, OutputInterface $output)
45
    {
46
        $manifestFilePath = $input->getArgument('manifest');
47
        
48
        $builder = new AssetBuilder($manifestFilePath);
49
50
        if ($input->getOption('minify')) {
51
            $builder->enableCompressor();
52
        }
53
        
54
        if ($input->getOption('freeze')) {
55
            $builder->enableFreezing();
56
        }
57
58
        $builder->build();
59
        $output->writeln('Assets succesfuly builded');
60
    }
61
}
62