PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.0
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.0
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
← All changes | back/Libraries/Sabberworm/CSS/src/Property/CSSNamespace.php +43 -100 10.0.1 → 11.1.0 View file →
@@ -1,154 +1,97 @@
1 1 <?php
2 2
3 -namespace Sabberworm\CSS\Property;
3 +declare(strict_types=1);
4 4
5 -use Sabberworm\CSS\Comment\Comment;
6 -use Sabberworm\CSS\OutputFormat;
5 +namespace AcyMailing\Libraries\Sabberworm\CSS\Property;
7 6
7 +use AcyMailing\Libraries\Sabberworm\CSS\Comment\CommentContainer;
8 +use AcyMailing\Libraries\Sabberworm\CSS\OutputFormat;
9 +use AcyMailing\Libraries\Sabberworm\CSS\Position\Position;
10 +use AcyMailing\Libraries\Sabberworm\CSS\Position\Positionable;
11 +use AcyMailing\Libraries\Sabberworm\CSS\Value\CSSString;
12 +use AcyMailing\Libraries\Sabberworm\CSS\Value\URL;
13 +
8 14 /**
9 15 * `CSSNamespace` represents an `@namespace` rule.
10 16 */
11 -class CSSNamespace implements AtRule
17 +class CSSNamespace implements AtRule, Positionable
12 18 {
13 - /**
14 - * @var string
15 - */
16 - private $mUrl;
19 + use CommentContainer;
20 + use Position;
17 21
18 22 /**
19 - * @var string
23 + * @var CSSString|URL
20 24 */
21 - private $sPrefix;
25 + private $url;
22 26
23 27 /**
24 - * @var int
28 + * @var string|null
25 29 */
26 - private $iLineNo;
30 + private $prefix;
27 31
28 32 /**
29 - * @var array<array-key, Comment>
33 + * @param CSSString|URL $url
34 + * @param int<1, max>|null $lineNumber
30 35 */
31 - protected $aComments;
32 -
33 - /**
34 - * @param string $mUrl
35 - * @param string|null $sPrefix
36 - * @param int $iLineNo
37 - */
38 - public function __construct($mUrl, $sPrefix = null, $iLineNo = 0)
36 + public function __construct($url, ?string $prefix = null, ?int $lineNumber = null)
39 37 {
40 - $this->mUrl = $mUrl;
41 - $this->sPrefix = $sPrefix;
42 - $this->iLineNo = $iLineNo;
43 - $this->aComments = [];
38 + $this->url = $url;
39 + $this->prefix = $prefix;
40 + $this->setPosition($lineNumber);
44 41 }
45 42
46 43 /**
47 - * @return int
44 + * @return non-empty-string
48 45 */
49 - public function getLineNo()
46 + public function render(OutputFormat $outputFormat): string
50 47 {
51 - return $this->iLineNo;
48 + return '@namespace ' . ($this->prefix === null ? '' : $this->prefix . ' ')
49 + . $this->url->render($outputFormat) . ';';
52 50 }
53 51
54 52 /**
55 - * @return string
53 + * @return CSSString|URL
56 54 */
57 - public function __toString()
58 - {
59 - return $this->render(new OutputFormat());
60 - }
61 -
62 - /**
63 - * @return string
64 - */
65 - public function render(OutputFormat $oOutputFormat)
66 - {
67 - return '@namespace ' . ($this->sPrefix === null ? '' : $this->sPrefix . ' ')
68 - . $this->mUrl->render($oOutputFormat) . ';';
69 - }
70 -
71 - /**
72 - * @return string
73 - */
74 55 public function getUrl()
75 56 {
76 - return $this->mUrl;
57 + return $this->url;
77 58 }
78 59
79 - /**
80 - * @return string|null
81 - */
82 - public function getPrefix()
60 + public function getPrefix(): ?string
83 61 {
84 - return $this->sPrefix;
62 + return $this->prefix;
85 63 }
86 64
87 65 /**
88 - * @param string $mUrl
89 - *
90 - * @return void
66 + * @param CSSString|URL $url
91 67 */
92 - public function setUrl($mUrl)
68 + public function setUrl($url): void
93 69 {
94 - $this->mUrl = $mUrl;
70 + $this->url = $url;
95 71 }
96 72
97 - /**
98 - * @param string $sPrefix
99 - *
100 - * @return void
101 - */
102 - public function setPrefix($sPrefix)
73 + public function setPrefix(string $prefix): void
103 74 {
104 - $this->sPrefix = $sPrefix;
75 + $this->prefix = $prefix;
105 76 }
106 77
107 78 /**
108 - * @return string
79 + * @return non-empty-string
109 80 */
110 - public function atRuleName()
81 + public function atRuleName(): string
111 82 {
112 83 return 'namespace';
113 84 }
114 85
115 86 /**
116 - * @return array<int, string>
87 + * @return array{0: CSSString|URL|non-empty-string, 1?: CSSString|URL}
117 88 */
118 - public function atRuleArgs()
89 + public function atRuleArgs(): array
119 90 {
120 - $aResult = [$this->mUrl];
121 - if ($this->sPrefix) {
122 - array_unshift($aResult, $this->sPrefix);
91 + $result = [$this->url];
92 + if (\is_string($this->prefix) && $this->prefix !== '') {
93 + \array_unshift($result, $this->prefix);
123 94 }
124 - return $aResult;
125 - }
126 -
127 - /**
128 - * @param array<array-key, Comment> $aComments
129 - *
130 - * @return void
131 - */
132 - public function addComments(array $aComments)
133 - {
134 - $this->aComments = array_merge($this->aComments, $aComments);
135 - }
136 -
137 - /**
138 - * @return array<array-key, Comment>
139 - */
140 - public function getComments()
141 - {
142 - return $this->aComments;
143 - }
144 -
145 - /**
146 - * @param array<array-key, Comment> $aComments
147 - *
148 - * @return void
149 - */
150 - public function setComments(array $aComments)
151 - {
152 - $this->aComments = $aComments;
95 + return $result;
153 96 }
154 97 }