Build   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 4
c 3
b 0
f 0
lcom 0
cbo 4
dl 0
loc 46
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 17 3
B configure() 0 25 1
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