-
Notifications
You must be signed in to change notification settings - Fork 9.3k
/
CSSmin.php
49 lines (43 loc) · 1.1 KB
/
CSSmin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Framework\Code\Minifier\Adapter\Css;
use CSSmin as CssMinLibrary;
use Magento\Framework\Code\Minifier\AdapterInterface;
/**
* Adapter for CSSmin library
*/
class CSSmin implements AdapterInterface
{
/**
* 'pcre.recursion_limit' value for CSSMin minification
*/
const PCRE_RECURSION_LIMIT = 1000;
/**
* @var CssMinLibrary
*/
protected $cssMinifier;
/**
* @param CssMinLibrary $cssMinifier
*/
public function __construct(CssMinLibrary $cssMinifier)
{
$this->cssMinifier = $cssMinifier;
}
/**
* Minify css file content
*
* @param string $content
* @return string
*/
public function minify($content)
{
$pcreRecursionLimit = ini_get('pcre.recursion_limit');
ini_set('pcre.recursion_limit', self::PCRE_RECURSION_LIMIT);
$result = $this->cssMinifier->run($content);
ini_set('pcre.recursion_limit', $pcreRecursionLimit);
return $result;
}
}