Skip to content

Commit afabc04

Browse files
committed
Make Charset actually return/take string, not CSSString as documented
1 parent 6c03912 commit afabc04

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/CSSList/CSSList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ private static function parseListItem(ParserState $oParserState, CSSList $oList)
128128
$oParserState->currentLine()
129129
);
130130
}
131-
$oParserState->setCharset($oAtRule->getCharset()->getString());
131+
$oParserState->setCharset($oAtRule->getCharset());
132132
}
133133
return $oAtRule;
134134
} elseif ($oParserState->comes('}')) {

src/Property/Charset.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Sabberworm\CSS\Comment\Comment;
66
use Sabberworm\CSS\OutputFormat;
7+
use Sabberworm\CSS\Value\CSSString;
78

89
/**
910
* Class representing an `@charset` rule.
@@ -16,9 +17,9 @@
1617
class 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

Comments
 (0)