44
55use Sabberworm \CSS \Comment \Comment ;
66use Sabberworm \CSS \OutputFormat ;
7+ use Sabberworm \CSS \Value \CSSString ;
78
89/**
910 * Class representing an `@charset` rule.
1617class Charset implements AtRule
1718{
1819 /**
19- * @var string
20+ * @var CSSString
2021 */
21- private $ sCharset ;
22+ private $ oCharset ;
2223
2324 /**
2425 * @var int
@@ -31,12 +32,12 @@ class Charset implements AtRule
3132 protected $ aComments ;
3233
3334 /**
34- * @param string $sCharset
35+ * @param CSSString $oCharset
3536 * @param int $iLineNo
3637 */
37- public function __construct ($ sCharset , $ iLineNo = 0 )
38+ public function __construct (CSSString $ oCharset , $ iLineNo = 0 )
3839 {
39- $ this ->sCharset = $ sCharset ;
40+ $ this ->oCharset = $ oCharset ;
4041 $ this ->iLineNo = $ iLineNo ;
4142 $ this ->aComments = [];
4243 }
@@ -50,21 +51,22 @@ public function getLineNo()
5051 }
5152
5253 /**
53- * @param string $sCharset
54+ * @param string|CSSString $oCharset
5455 *
5556 * @return void
5657 */
5758 public function setCharset ($ sCharset )
5859 {
59- $ this ->sCharset = $ sCharset ;
60+ $ sCharset = $ sCharset instanceof CSSString ? $ sCharset : new CSSString ($ sCharset );
61+ $ this ->oCharset = $ sCharset ;
6062 }
6163
6264 /**
6365 * @return string
6466 */
6567 public function getCharset ()
6668 {
67- return $ this ->sCharset ;
69+ return $ this ->oCharset -> getString () ;
6870 }
6971
7072 /**
@@ -96,7 +98,7 @@ public function atRuleName()
9698 */
9799 public function atRuleArgs ()
98100 {
99- return $ this ->sCharset ;
101+ return $ this ->oCharset ;
100102 }
101103
102104 /**
0 commit comments