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/Import.php +38 -90 10.1.4 → 11.1.0 View file →
@@ -1,137 +1,85 @@
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;
7 -use Sabberworm\CSS\Value\URL;
5 +namespace AcyMailing\Libraries\Sabberworm\CSS\Property;
8 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\URL;
12 +
9 13 /**
10 14 * Class representing an `@import` rule.
11 15 */
12 -class Import implements AtRule
16 +class Import implements AtRule, Positionable
13 17 {
18 + use CommentContainer;
19 + use Position;
20 +
14 21 /**
15 22 * @var URL
16 23 */
17 - private $oLocation;
24 + private $location;
18 25
19 26 /**
20 - * @var string
27 + * @var string|null
21 28 */
22 - private $sMediaQuery;
29 + private $mediaQuery;
23 30
24 31 /**
25 - * @var int
32 + * @param int<1, max>|null $lineNumber
26 33 */
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)
34 + public function __construct(URL $location, ?string $mediaQuery, ?int $lineNumber = null)
40 35 {
41 - $this->oLocation = $oLocation;
42 - $this->sMediaQuery = $sMediaQuery;
43 - $this->iLineNo = $iLineNo;
44 - $this->aComments = [];
36 + $this->location = $location;
37 + $this->mediaQuery = $mediaQuery;
38 + $this->setPosition($lineNumber);
45 39 }
46 40
47 - /**
48 - * @return int
49 - */
50 - public function getLineNo()
41 + public function setLocation(URL $location): void
51 42 {
52 - return $this->iLineNo;
43 + $this->location = $location;
53 44 }
54 45
55 - /**
56 - * @param URL $oLocation
57 - *
58 - * @return void
59 - */
60 - public function setLocation($oLocation)
46 + public function getLocation(): URL
61 47 {
62 - $this->oLocation = $oLocation;
48 + return $this->location;
63 49 }
64 50
65 51 /**
66 - * @return URL
52 + * @return non-empty-string
67 53 */
68 - public function getLocation()
54 + public function render(OutputFormat $outputFormat): string
69 55 {
70 - return $this->oLocation;
56 + return $outputFormat->getFormatter()->comments($this) . '@import ' . $this->location->render($outputFormat)
57 + . ($this->mediaQuery === null ? '' : ' ' . $this->mediaQuery) . ';';
71 58 }
72 59
73 60 /**
74 - * @return string
61 + * @return non-empty-string
75 62 */
76 - public function __toString()
63 + public function atRuleName(): string
77 64 {
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 65 return 'import';
96 66 }
97 67
98 68 /**
99 - * @return array<int, URL|string>
69 + * @return array{0: URL, 1?: non-empty-string}
100 70 */
101 - public function atRuleArgs()
71 + public function atRuleArgs(): array
102 72 {
103 - $aResult = [$this->oLocation];
104 - if ($this->sMediaQuery) {
105 - array_push($aResult, $this->sMediaQuery);
73 + $result = [$this->location];
74 + if (\is_string($this->mediaQuery) && $this->mediaQuery !== '') {
75 + $result[] = $this->mediaQuery;
106 76 }
107 - return $aResult;
108 - }
109 77
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);
78 + return $result;
118 79 }
119 80
120 - /**
121 - * @return array<array-key, Comment>
122 - */
123 - public function getComments()
81 + public function getMediaQuery(): ?string
124 82 {
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;
83 + return $this->mediaQuery;
136 84 }
137 85 }