PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.0.4
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.0.4
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
acymailing / back / Libraries / Sabberworm / CSS / src / Value / ValueList.php

ValueList.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 11.0.4, at back/Libraries/Sabberworm/CSS/src/Value/ValueList.php

97 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace AcyMailing\Libraries\Sabberworm\CSS\Value;
6
7 use AcyMailing\Libraries\Sabberworm\CSS\OutputFormat;
8
9 /**
10 * A `ValueList` represents a lists of `Value`s, separated by some separation character
11 * (mostly `,`, whitespace, or `/`).
12 *
13 * There are two types of `ValueList`s: `RuleValueList` and `CSSFunction`
14 */
15 abstract class ValueList extends Value
16 {
17 /**
18 * @var array<Value|string>
19 *
20 * @internal since 8.8.0
21 */
22 protected $components;
23
24 /**
25 * @var non-empty-string
26 *
27 * @internal since 8.8.0
28 */
29 protected $separator;
30
31 /**
32 * @param array<Value|string>|Value|string $components
33 * @param non-empty-string $separator
34 * @param int<1, max>|null $lineNumber
35 */
36 public function __construct($components = [], $separator = ',', ?int $lineNumber = null)
37 {
38 parent::__construct($lineNumber);
39 if (!\is_array($components)) {
40 $components = [$components];
41 }
42 $this->components = $components;
43 $this->separator = $separator;
44 }
45
46 /**
47 * @param Value|string $component
48 */
49 public function addListComponent($component): void
50 {
51 $this->components[] = $component;
52 }
53
54 /**
55 * @return array<Value|string>
56 */
57 public function getListComponents(): array
58 {
59 return $this->components;
60 }
61
62 /**
63 * @param array<Value|string> $components
64 */
65 public function setListComponents(array $components): void
66 {
67 $this->components = $components;
68 }
69
70 /**
71 * @return non-empty-string
72 */
73 public function getListSeparator(): string
74 {
75 return $this->separator;
76 }
77
78 /**
79 * @param non-empty-string $separator
80 */
81 public function setListSeparator(string $separator): void
82 {
83 $this->separator = $separator;
84 }
85
86 public function render(OutputFormat $outputFormat): string
87 {
88 $formatter = $outputFormat->getFormatter();
89
90 return $formatter->implode(
91 $formatter->spaceBeforeListArgumentSeparator($this->separator) . $this->separator
92 . $formatter->spaceAfterListArgumentSeparator($this->separator),
93 $this->components
94 );
95 }
96 }
97