4
4
5
5
use Sabberworm \CSS \Comment \Comment ;
6
6
use Sabberworm \CSS \OutputFormat ;
7
+ use Sabberworm \CSS \Value \CSSString ;
7
8
8
9
/**
9
10
* Class representing an `@charset` rule.
16
17
class Charset implements AtRule
17
18
{
18
19
/**
19
- * @var string
20
+ * @var CSSString
20
21
*/
21
- private $ sCharset ;
22
+ private $ oCharset ;
22
23
23
24
/**
24
25
* @var int
@@ -31,12 +32,12 @@ class Charset implements AtRule
31
32
protected $ aComments ;
32
33
33
34
/**
34
- * @param string $sCharset
35
+ * @param CSSString $oCharset
35
36
* @param int $iLineNo
36
37
*/
37
- public function __construct ($ sCharset , $ iLineNo = 0 )
38
+ public function __construct (CSSString $ oCharset , $ iLineNo = 0 )
38
39
{
39
- $ this ->sCharset = $ sCharset ;
40
+ $ this ->oCharset = $ oCharset ;
40
41
$ this ->iLineNo = $ iLineNo ;
41
42
$ this ->aComments = [];
42
43
}
@@ -50,21 +51,22 @@ public function getLineNo()
50
51
}
51
52
52
53
/**
53
- * @param string $sCharset
54
+ * @param string|CSSString $oCharset
54
55
*
55
56
* @return void
56
57
*/
57
58
public function setCharset ($ sCharset )
58
59
{
59
- $ this ->sCharset = $ sCharset ;
60
+ $ sCharset = $ sCharset instanceof CSSString ? $ sCharset : new CSSString ($ sCharset );
61
+ $ this ->oCharset = $ sCharset ;
60
62
}
61
63
62
64
/**
63
65
* @return string
64
66
*/
65
67
public function getCharset ()
66
68
{
67
- return $ this ->sCharset ;
69
+ return $ this ->oCharset -> getString () ;
68
70
}
69
71
70
72
/**
@@ -96,7 +98,7 @@ public function atRuleName()
96
98
*/
97
99
public function atRuleArgs ()
98
100
{
99
- return $ this ->sCharset ;
101
+ return $ this ->oCharset ;
100
102
}
101
103
102
104
/**
0 commit comments