MDL-65759 library: Update php-css-parser to 8.3.0
[moodle.git] / lib / php-css-parser / Settings.php
CommitLineData
fbe18cc0
FM
1<?php
2
3namespace Sabberworm\CSS;
4
5use Sabberworm\CSS\Rule\Rule;
6
7/**
8 * Parser settings class.
9 *
10 * Configure parser behaviour here.
11 */
12class Settings {
13 /**
14 * Multi-byte string support. If true (mbstring extension must be enabled), will use (slower) mb_strlen, mb_convert_case, mb_substr and mb_strpos functions. Otherwise, the normal (ASCII-Only) functions will be used.
15 */
16 public $bMultibyteSupport;
17
18 /**
19 * The default charset for the CSS if no `@charset` rule is found. Defaults to utf-8.
20 */
21 public $sDefaultCharset = 'utf-8';
22
23 /**
24 * Lenient parsing. When used (which is true by default), the parser will not choke on unexpected tokens but simply ignore them.
25 */
26 public $bLenientParsing = true;
27
28 private function __construct() {
29 $this->bMultibyteSupport = extension_loaded('mbstring');
30 }
31
32 public static function create() {
33 return new Settings();
34 }
35
36 public function withMultibyteSupport($bMultibyteSupport = true) {
37 $this->bMultibyteSupport = $bMultibyteSupport;
38 return $this;
39 }
40
41 public function withDefaultCharset($sDefaultCharset) {
42 $this->sDefaultCharset = $sDefaultCharset;
43 return $this;
44 }
45
46 public function withLenientParsing($bLenientParsing = true) {
47 $this->bLenientParsing = $bLenientParsing;
48 return $this;
49 }
50
51 public function beStrict() {
52 return $this->withLenientParsing(false);
53 }
54}