Merge branch 'MDL-73076-master' of https://github.com/lameze/moodle
[moodle.git] / lib / php-css-parser / Settings.php
blobcb89a8636ba7e4edd552373a05c5944fbd8ee8b4
1 <?php
3 namespace Sabberworm\CSS;
5 use Sabberworm\CSS\Rule\Rule;
7 /**
8 * Parser settings class.
10 * Configure parser behaviour here.
12 class 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.
16 public $bMultibyteSupport;
18 /**
19 * The default charset for the CSS if no `@charset` rule is found. Defaults to utf-8.
21 public $sDefaultCharset = 'utf-8';
23 /**
24 * Lenient parsing. When used (which is true by default), the parser will not choke on unexpected tokens but simply ignore them.
26 public $bLenientParsing = true;
28 private function __construct() {
29 $this->bMultibyteSupport = extension_loaded('mbstring');
32 public static function create() {
33 return new Settings();
36 public function withMultibyteSupport($bMultibyteSupport = true) {
37 $this->bMultibyteSupport = $bMultibyteSupport;
38 return $this;
41 public function withDefaultCharset($sDefaultCharset) {
42 $this->sDefaultCharset = $sDefaultCharset;
43 return $this;
46 public function withLenientParsing($bLenientParsing = true) {
47 $this->bLenientParsing = $bLenientParsing;
48 return $this;
51 public function beStrict() {
52 return $this->withLenientParsing(false);