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
CSSNamespace.php
72 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 | class CSSNamespace implements AtRule |
| 7 | { |
| 8 | private $mUrl; |
| 9 | private $sPrefix; |
| 10 | private $iLineNo; |
| 11 | protected $aComments; |
| 12 | public function __construct($mUrl, $sPrefix = null, $iLineNo = 0) |
| 13 | { |
| 14 | $this->mUrl = $mUrl; |
| 15 | $this->sPrefix = $sPrefix; |
| 16 | $this->iLineNo = $iLineNo; |
| 17 | $this->aComments = []; |
| 18 | } |
| 19 | public function getLineNo() |
| 20 | { |
| 21 | return $this->iLineNo; |
| 22 | } |
| 23 | public function __toString() |
| 24 | { |
| 25 | return $this->render(new OutputFormat()); |
| 26 | } |
| 27 | public function render(OutputFormat $oOutputFormat) |
| 28 | { |
| 29 | return '@namespace ' . ($this->sPrefix === null ? '' : $this->sPrefix . ' ') . $this->mUrl->render($oOutputFormat) . ';'; |
| 30 | } |
| 31 | public function getUrl() |
| 32 | { |
| 33 | return $this->mUrl; |
| 34 | } |
| 35 | public function getPrefix() |
| 36 | { |
| 37 | return $this->sPrefix; |
| 38 | } |
| 39 | public function setUrl($mUrl) |
| 40 | { |
| 41 | $this->mUrl = $mUrl; |
| 42 | } |
| 43 | public function setPrefix($sPrefix) |
| 44 | { |
| 45 | $this->sPrefix = $sPrefix; |
| 46 | } |
| 47 | public function atRuleName() |
| 48 | { |
| 49 | return 'namespace'; |
| 50 | } |
| 51 | public function atRuleArgs() |
| 52 | { |
| 53 | $aResult = [$this->mUrl]; |
| 54 | if ($this->sPrefix) { |
| 55 | \array_unshift($aResult, $this->sPrefix); |
| 56 | } |
| 57 | return $aResult; |
| 58 | } |
| 59 | public function addComments(array $aComments) |
| 60 | { |
| 61 | $this->aComments = \array_merge($this->aComments, $aComments); |
| 62 | } |
| 63 | public function getComments() |
| 64 | { |
| 65 | return $this->aComments; |
| 66 | } |
| 67 | public function setComments(array $aComments) |
| 68 | { |
| 69 | $this->aComments = $aComments; |
| 70 | } |
| 71 | } |
| 72 |