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