Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403]
1 <?php 2 3 namespace Sabberworm\CSS\Property; 4 5 use Sabberworm\CSS\Comment\Comment; 6 use Sabberworm\CSS\OutputFormat; 7 use Sabberworm\CSS\Value\URL; 8 9 /** 10 * Class representing an `@import` rule. 11 */ 12 class Import implements AtRule 13 { 14 /** 15 * @var URL 16 */ 17 private $oLocation; 18 19 /** 20 * @var string 21 */ 22 private $sMediaQuery; 23 24 /** 25 * @var int 26 */ 27 protected $iLineNo; 28 29 /** 30 * @var array<array-key, Comment> 31 */ 32 protected $aComments; 33 34 /** 35 * @param URL $oLocation 36 * @param string $sMediaQuery 37 * @param int $iLineNo 38 */ 39 public function __construct(URL $oLocation, $sMediaQuery, $iLineNo = 0) 40 { 41 $this->oLocation = $oLocation; 42 $this->sMediaQuery = $sMediaQuery; 43 $this->iLineNo = $iLineNo; 44 $this->aComments = []; 45 } 46 47 /** 48 * @return int 49 */ 50 public function getLineNo() 51 { 52 return $this->iLineNo; 53 } 54 55 /** 56 * @param URL $oLocation 57 * 58 * @return void 59 */ 60 public function setLocation($oLocation) 61 { 62 $this->oLocation = $oLocation; 63 } 64 65 /** 66 * @return URL 67 */ 68 public function getLocation() 69 { 70 return $this->oLocation; 71 } 72 73 /** 74 * @return string 75 */ 76 public function __toString() 77 { 78 return $this->render(new OutputFormat()); 79 } 80 81 /** 82 * @return string 83 */ 84 public function render(OutputFormat $oOutputFormat) 85 { 86 return "@import " . $this->oLocation->render($oOutputFormat) 87 . ($this->sMediaQuery === null ? '' : ' ' . $this->sMediaQuery) . ';'; 88 } 89 90 /** 91 * @return string 92 */ 93 public function atRuleName() 94 { 95 return 'import'; 96 } 97 98 /** 99 * @return array<int, URL|string> 100 */ 101 public function atRuleArgs() 102 { 103 $aResult = [$this->oLocation]; 104 if ($this->sMediaQuery) { 105 array_push($aResult, $this->sMediaQuery); 106 } 107 return $aResult; 108 } 109 110 /** 111 * @param array<array-key, Comment> $aComments 112 * 113 * @return void 114 */ 115 public function addComments(array $aComments) 116 { 117 $this->aComments = array_merge($this->aComments, $aComments); 118 } 119 120 /** 121 * @return array<array-key, Comment> 122 */ 123 public function getComments() 124 { 125 return $this->aComments; 126 } 127 128 /** 129 * @param array<array-key, Comment> $aComments 130 * 131 * @return void 132 */ 133 public function setComments(array $aComments) 134 { 135 $this->aComments = $aComments; 136 } 137 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body