1 | <?php |
||
8 | class Css2Less |
||
9 | { |
||
10 | /** |
||
11 | * @var string $cssContent |
||
12 | */ |
||
13 | protected $cssContent; |
||
14 | |||
15 | /** |
||
16 | * @var \CssParser $parser |
||
17 | */ |
||
18 | protected $parser; |
||
19 | |||
20 | /** |
||
21 | * Tokens. |
||
22 | * |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $tokens = []; |
||
26 | |||
27 | /** |
||
28 | * Nested CSS tree |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $lessTree = []; |
||
33 | |||
34 | /** |
||
35 | * List of CSS rules |
||
36 | * |
||
37 | * @var LessRuleList |
||
38 | */ |
||
39 | protected $ruleSetList; |
||
40 | |||
41 | /** |
||
42 | * Variables. |
||
43 | * |
||
44 | * @var array |
||
45 | */ |
||
46 | protected $variables = []; |
||
47 | |||
48 | /** |
||
49 | * Create a new parser object, use parameter to specify CSS you |
||
50 | * wish to convert into a LESS file |
||
51 | * |
||
52 | * @param string $cssContent |
||
53 | */ |
||
54 | 10 | public function __construct($cssContent) |
|
59 | |||
60 | /** |
||
61 | * Iterates through all tokens and extracts the values into variables |
||
62 | */ |
||
63 | 1 | protected function extractVariables() |
|
82 | |||
83 | /** |
||
84 | * Returns a string containing all variables to be printed in the output |
||
85 | * |
||
86 | * @return string |
||
87 | */ |
||
88 | 1 | protected function getVariables() |
|
99 | |||
100 | /** |
||
101 | * Returns a string containing the LESS content matching the CSS input |
||
102 | * @return string |
||
103 | */ |
||
104 | 10 | public function getLess($extractVariables = false) |
|
132 | |||
133 | /** |
||
134 | * Build a nested tree based on the flat CSS tokens |
||
135 | */ |
||
136 | 10 | protected function buildNestedTree() |
|
174 | } |
||
175 |