PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / trunk
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress vtrunk
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 / Property / Charset.php

Charset.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress trunk, at back/Libraries/Sabberworm/CSS/src/Property/Charset.php

75 lines 1.8 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\Property;
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
13 /**
14 * Class representing an `@charset` rule.
15 *
16 * The following restrictions apply:
17 * - May not be found in any CSSList other than the Document.
18 * - May only appear at the very top of a Document’s contents.
19 * - Must not appear more than once.
20 */
21 class Charset implements AtRule, Positionable
22 {
23 use CommentContainer;
24 use Position;
25
26 /**
27 * @var CSSString
28 */
29 private $charset;
30
31 /**
32 * @param int<1, max>|null $lineNumber
33 */
34 public function __construct(CSSString $charset, ?int $lineNumber = null)
35 {
36 $this->charset = $charset;
37 $this->setPosition($lineNumber);
38 }
39
40 /**
41 * @param string|CSSString $charset
42 */
43 public function setCharset($charset): void
44 {
45 $charset = $charset instanceof CSSString ? $charset : new CSSString($charset);
46 $this->charset = $charset;
47 }
48
49 public function getCharset(): string
50 {
51 return $this->charset->getString();
52 }
53
54 /**
55 * @return non-empty-string
56 */
57 public function render(OutputFormat $outputFormat): string
58 {
59 return "{$outputFormat->getFormatter()->comments($this)}@charset {$this->charset->render($outputFormat)};";
60 }
61
62 /**
63 * @return non-empty-string
64 */
65 public function atRuleName(): string
66 {
67 return 'charset';
68 }
69
70 public function atRuleArgs(): CSSString
71 {
72 return $this->charset;
73 }
74 }
75