Passed
Push — master ( d1c5a6...bac8bf )
by Fabian
03:36 queued 12s
created

BuildCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 36
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 7 1
A __construct() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Fabiang\AsseticBundle\Cli;
6
7
use Fabiang\AsseticBundle\Service;
8
use Symfony\Component\Console\Command\Command;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12
class BuildCommand extends Command
13
{
14
15
    /**
16
     * The assetic service
17
18
     */
19
    private Service $assetic;
20
21
    /**
22
     * Constructor.
23
     */
24
    public function __construct(Service $assetic)
25
    {
26
        parent::__construct('build');
27
        $this->assetic = $assetic;
28
        $this->setDescription('Build all assets.');
29
    }
30
31
    /**
32
     * Executes the current command.
33
     */
34
    protected function execute(InputInterface $input, OutputInterface $output): int
35
    {
36
        $config = $this->assetic->getConfiguration();
37
        $config->setBuildOnRequest(true);
38
        $this->assetic->build();
39
        $this->assetic->getAssetWriter()->writeManagerAssets($this->assetic->getAssetManager());
40
        return 0;
41
    }
42
43
}
44