| @@ -1,9 +1,13 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -namespace Sabberworm\CSS; | |
| 3 | +declare(strict_types=1); | |
| 4 | 4 | |
| 5 | +namespace AcyMailing\Libraries\Sabberworm\CSS; | |
| 6 | + | |
| 5 | 7 | /** |
| 8 | + * version 9.1.0 | |
| 9 | + * | |
| 6 | 10 | * Parser settings class. |
| 7 | 11 | * |
| 8 | 12 | * Configure parser behaviour here. |
| 9 | 13 | */ |
| @@ -10,80 +14,113 @@ | ||
| 10 | 14 | class Settings |
| 11 | 15 | { |
| 12 | 16 | /** |
| 13 | 17 | * Multi-byte string support. |
| 14 | - * If true (mbstring extension must be enabled), will use (slower) `mb_strlen`, `mb_convert_case`, `mb_substr` | |
| 18 | + * | |
| 19 | + * If `true` (`mbstring` extension must be enabled), will use (slower) `mb_strlen`, `mb_convert_case`, `mb_substr` | |
| 15 | 20 | * and `mb_strpos` functions. Otherwise, the normal (ASCII-Only) functions will be used. |
| 16 | 21 | * |
| 17 | 22 | * @var bool |
| 18 | 23 | */ |
| 19 | - public $bMultibyteSupport; | |
| 24 | + private $multibyteSupport; | |
| 20 | 25 | |
| 21 | 26 | /** |
| 22 | - * The default charset for the CSS if no `@charset` rule is found. Defaults to utf-8. | |
| 27 | + * The default charset for the CSS if no `@charset` declaration is found. Defaults to utf-8. | |
| 23 | 28 | * |
| 24 | - * @var string | |
| 29 | + * @var non-empty-string | |
| 25 | 30 | */ |
| 26 | - public $sDefaultCharset = 'utf-8'; | |
| 31 | + private $defaultCharset = 'utf-8'; | |
| 27 | 32 | |
| 28 | 33 | /** |
| 29 | - * Lenient parsing. When used (which is true by default), the parser will not choke | |
| 30 | - * on unexpected tokens but simply ignore them. | |
| 34 | + * Whether the parser silently ignore invalid rules instead of choking on them. | |
| 31 | 35 | * |
| 32 | 36 | * @var bool |
| 33 | 37 | */ |
| 34 | - public $bLenientParsing = true; | |
| 38 | + private $lenientParsing = true; | |
| 35 | 39 | |
| 36 | 40 | private function __construct() |
| 37 | 41 | { |
| 38 | - $this->bMultibyteSupport = extension_loaded('mbstring'); | |
| 42 | + $this->multibyteSupport = \extension_loaded('mbstring'); | |
| 39 | 43 | } |
| 40 | 44 | |
| 41 | - /** | |
| 42 | - * @return self new instance | |
| 43 | - */ | |
| 44 | - public static function create() | |
| 45 | + public static function create(): self | |
| 45 | 46 | { |
| 46 | 47 | return new Settings(); |
| 47 | 48 | } |
| 48 | 49 | |
| 49 | 50 | /** |
| 50 | - * @param bool $bMultibyteSupport | |
| 51 | + * Enables/disables multi-byte string support. | |
| 51 | 52 | * |
| 52 | - * @return self fluent interface | |
| 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 | |
| 53 | 57 | */ |
| 54 | - public function withMultibyteSupport($bMultibyteSupport = true) | |
| 58 | + public function withMultibyteSupport(bool $multibyteSupport = true): self | |
| 55 | 59 | { |
| 56 | - $this->bMultibyteSupport = $bMultibyteSupport; | |
| 60 | + $this->multibyteSupport = $multibyteSupport; | |
| 61 | + | |
| 57 | 62 | return $this; |
| 58 | 63 | } |
| 59 | 64 | |
| 60 | 65 | /** |
| 61 | - * @param string $sDefaultCharset | |
| 66 | + * Sets the charset to be used if the CSS does not contain an `@charset` declaration. | |
| 62 | 67 | * |
| 63 | - * @return self fluent interface | |
| 68 | + * @param non-empty-string $defaultCharset | |
| 69 | + * | |
| 70 | + * @return $this fluent interface | |
| 64 | 71 | */ |
| 65 | - public function withDefaultCharset($sDefaultCharset) | |
| 72 | + public function withDefaultCharset(string $defaultCharset): self | |
| 66 | 73 | { |
| 67 | - $this->sDefaultCharset = $sDefaultCharset; | |
| 74 | + $this->defaultCharset = $defaultCharset; | |
| 75 | + | |
| 68 | 76 | return $this; |
| 69 | 77 | } |
| 70 | 78 | |
| 71 | 79 | /** |
| 72 | - * @param bool $bLenientParsing | |
| 80 | + * Configures whether the parser should silently ignore invalid rules. | |
| 73 | 81 | * |
| 74 | - * @return self fluent interface | |
| 82 | + * @return $this fluent interface | |
| 75 | 83 | */ |
| 76 | - public function withLenientParsing($bLenientParsing = true) | |
| 84 | + public function withLenientParsing(bool $usesLenientParsing = true): self | |
| 77 | 85 | { |
| 78 | - $this->bLenientParsing = $bLenientParsing; | |
| 86 | + $this->lenientParsing = $usesLenientParsing; | |
| 87 | + | |
| 79 | 88 | return $this; |
| 80 | 89 | } |
| 81 | 90 | |
| 82 | 91 | /** |
| 83 | - * @return self fluent interface | |
| 92 | + * Configures the parser to choke on invalid rules. | |
| 93 | + * | |
| 94 | + * @return $this fluent interface | |
| 84 | 95 | */ |
| 85 | - public function beStrict() | |
| 96 | + public function beStrict(): self | |
| 86 | 97 | { |
| 87 | 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; | |
| 88 | 125 | } |
| 89 | 126 | } |