PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.0.3
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.0.3
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 / Settings.php

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

127 lines 2.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;
6
7 /**
8 * version 9.1.0
9 *
10 * Parser settings class.
11 *
12 * Configure parser behaviour here.
13 */
14 class Settings
15 {
16 /**
17 * Multi-byte string support.
18 *
19 * If `true` (`mbstring` extension must be enabled), will use (slower) `mb_strlen`, `mb_convert_case`, `mb_substr`
20 * and `mb_strpos` functions. Otherwise, the normal (ASCII-Only) functions will be used.
21 *
22 * @var bool
23 */
24 private $multibyteSupport;
25
26 /**
27 * The default charset for the CSS if no `@charset` declaration is found. Defaults to utf-8.
28 *
29 * @var non-empty-string
30 */
31 private $defaultCharset = 'utf-8';
32
33 /**
34 * Whether the parser silently ignore invalid rules instead of choking on them.
35 *
36 * @var bool
37 */
38 private $lenientParsing = true;
39
40 private function __construct()
41 {
42 $this->multibyteSupport = \extension_loaded('mbstring');
43 }
44
45 public static function create(): self
46 {
47 return new Settings();
48 }
49
50 /**
51 * Enables/disables multi-byte string support.
52 *
53 * If `true` (`mbstring` extension must be enabled), will use (slower) `mb_strlen`, `mb_convert_case`, `mb_substr`
54 * and `mb_strpos` functions. Otherwise, the normal (ASCII-Only) functions will be used.
55 *
56 * @return $this fluent interface
57 */
58 public function withMultibyteSupport(bool $multibyteSupport = true): self
59 {
60 $this->multibyteSupport = $multibyteSupport;
61
62 return $this;
63 }
64
65 /**
66 * Sets the charset to be used if the CSS does not contain an `@charset` declaration.
67 *
68 * @param non-empty-string $defaultCharset
69 *
70 * @return $this fluent interface
71 */
72 public function withDefaultCharset(string $defaultCharset): self
73 {
74 $this->defaultCharset = $defaultCharset;
75
76 return $this;
77 }
78
79 /**
80 * Configures whether the parser should silently ignore invalid rules.
81 *
82 * @return $this fluent interface
83 */
84 public function withLenientParsing(bool $usesLenientParsing = true): self
85 {
86 $this->lenientParsing = $usesLenientParsing;
87
88 return $this;
89 }
90
91 /**
92 * Configures the parser to choke on invalid rules.
93 *
94 * @return $this fluent interface
95 */
96 public function beStrict(): self
97 {
98 return $this->withLenientParsing(false);
99 }
100
101 /**
102 * @internal
103 */
104 public function hasMultibyteSupport(): bool
105 {
106 return $this->multibyteSupport;
107 }
108
109 /**
110 * @return non-empty-string
111 *
112 * @internal
113 */
114 public function getDefaultCharset(): string
115 {
116 return $this->defaultCharset;
117 }
118
119 /**
120 * @internal
121 */
122 public function usesLenientParsing(): bool
123 {
124 return $this->lenientParsing;
125 }
126 }
127