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

BuildCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
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