Passed
Pull Request — development (#671)
by Nick
06:47
created

CreateWebCacheCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 48
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 8 1
A execute() 0 19 1
1
<?php
2
/***************************************************************************
3
 * for license information see LICENSE.md
4
 ***************************************************************************/
5
6
namespace Oc\Command;
7
8
use Leafo\ScssPhp\Compiler;
9
use Symfony\Component\Console\Exception\InvalidArgumentException;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Output\OutputInterface;
12
13
/**
14
 * Class CreateWebCacheCommand
15
 *
16
 * @package Oc\Command
17
 */
18
class CreateWebCacheCommand extends AbstractCommand
19
{
20
    const COMMAND_NAME = 'cache:web:create';
21
22
    /**
23
     * Configures the command.
24
     *
25
     * @return void
26
     *
27
     * @throws InvalidArgumentException
28
     */
29
    protected function configure()
30
    {
31
        parent::configure();
32
33
        $this
34
            ->setName(self::COMMAND_NAME)
35
            ->setDescription('create legacy web caches');
36
    }
37
38
    /**
39
     * Executes the command.
40
     *
41
     * @param InputInterface $input
42
     * @param OutputInterface $output
43
     *
44
     * @return int|null
45
     */
46
    protected function execute(InputInterface $input, OutputInterface $output)
47
    {
48
        $output->writeln('generate style.css');
49
50
        $scss = new Compiler();
51
        $scss->setImportPaths(
52
            [
53
                __DIR__ . '/../../../vendor/twbs/bootstrap/scss/',
54
                __DIR__ . '/../../../theme/scss/',
55
            ]
56
        );
57
58
        file_put_contents(
59
            __DIR__ . '/../../../web/css/style.css',
60
            $scss->compile('@import "all.scss";')
61
        );
62
63
        $output->writeln('style.css generated');
64
    }
65
}
66