AtRule.php
4 years ago
CSSNamespace.php
4 years ago
Charset.php
2 years ago
Import.php
2 years ago
KeyframeSelector.php
4 years ago
Selector.php
4 years ago
index.php
3 years ago
Charset.php
60 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Sabberworm\CSS\Property; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | use MailPoetVendor\Sabberworm\CSS\Comment\Comment; |
| 5 | use MailPoetVendor\Sabberworm\CSS\OutputFormat; |
| 6 | use MailPoetVendor\Sabberworm\CSS\Value\CSSString; |
| 7 | class Charset implements AtRule |
| 8 | { |
| 9 | private $oCharset; |
| 10 | protected $iLineNo; |
| 11 | protected $aComments; |
| 12 | public function __construct(CSSString $oCharset, $iLineNo = 0) |
| 13 | { |
| 14 | $this->oCharset = $oCharset; |
| 15 | $this->iLineNo = $iLineNo; |
| 16 | $this->aComments = []; |
| 17 | } |
| 18 | public function getLineNo() |
| 19 | { |
| 20 | return $this->iLineNo; |
| 21 | } |
| 22 | public function setCharset($sCharset) |
| 23 | { |
| 24 | $sCharset = $sCharset instanceof CSSString ? $sCharset : new CSSString($sCharset); |
| 25 | $this->oCharset = $sCharset; |
| 26 | } |
| 27 | public function getCharset() |
| 28 | { |
| 29 | return $this->oCharset->getString(); |
| 30 | } |
| 31 | public function __toString() |
| 32 | { |
| 33 | return $this->render(new OutputFormat()); |
| 34 | } |
| 35 | public function render(OutputFormat $oOutputFormat) |
| 36 | { |
| 37 | return "{$oOutputFormat->comments($this)}@charset {$this->oCharset->render($oOutputFormat)};"; |
| 38 | } |
| 39 | public function atRuleName() |
| 40 | { |
| 41 | return 'charset'; |
| 42 | } |
| 43 | public function atRuleArgs() |
| 44 | { |
| 45 | return $this->oCharset; |
| 46 | } |
| 47 | public function addComments(array $aComments) |
| 48 | { |
| 49 | $this->aComments = \array_merge($this->aComments, $aComments); |
| 50 | } |
| 51 | public function getComments() |
| 52 | { |
| 53 | return $this->aComments; |
| 54 | } |
| 55 | public function setComments(array $aComments) |
| 56 | { |
| 57 | $this->aComments = $aComments; |
| 58 | } |
| 59 | } |
| 60 |