Passed
Push — master ( 8a23c2...e496ae )
by Christian
13:05 queued 10s
created

Autoprefixer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 1
f 0
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Storefront\Theme;
4
5
use Padaliyajay\PHPAutoprefixer\Autoprefixer as PadaliyajayAutoprefixer;
6
use Sabberworm\CSS\OutputFormat;
7
use Sabberworm\CSS\Parser;
8
9
/*
10
 * This class implements a pull request of the core autoprefixer, to enable
11
 * minification of the compiled CSS, if the update is released this
12
 * class should be removed and Padaliyajay\PHPAutoprefixer\Autoprefixer should
13
 * be used instead, see:
14
 * https://github.com/padaliyajay/php-autoprefixer/pull/8
15
 * https://github.com/padaliyajay/php-autoprefixer/issues/10
16
 */
17
class Autoprefixer extends PadaliyajayAutoprefixer
18
{
19
    /**
20
     * @var Parser
21
     */
22
    private $cssParser;
23
24
    public function __construct(string $cssCode)
25
    {
26
        $this->cssParser = new Parser($cssCode);
27
    }
28
29
    public function compile(bool $prettyOutput = true): string
30
    {
31
        $cssDocument = $this->cssParser->parse();
32
33
        $this->compileCSSList($cssDocument);
34
35
        $outputFormat = $prettyOutput
36
            ? OutputFormat::createPretty()
37
            : OutputFormat::createCompact();
38
39
        return $cssDocument->render($outputFormat);
40
    }
41
}
42