3 namespace Sabberworm\CSS
;
6 * Parser settings class.
8 * Configure parser behaviour here.
13 * Multi-byte string support.
14 * If true (mbstring extension must be enabled), will use (slower) `mb_strlen`, `mb_convert_case`, `mb_substr`
15 * and `mb_strpos` functions. Otherwise, the normal (ASCII-Only) functions will be used.
19 public $bMultibyteSupport;
22 * The default charset for the CSS if no `@charset` rule is found. Defaults to utf-8.
26 public $sDefaultCharset = 'utf-8';
29 * Lenient parsing. When used (which is true by default), the parser will not choke
30 * on unexpected tokens but simply ignore them.
34 public $bLenientParsing = true;
36 private function __construct()
38 $this->bMultibyteSupport
= extension_loaded('mbstring');
42 * @return self new instance
44 public static function create()
46 return new Settings();
50 * @param bool $bMultibyteSupport
52 * @return self fluent interface
54 public function withMultibyteSupport($bMultibyteSupport = true)
56 $this->bMultibyteSupport
= $bMultibyteSupport;
61 * @param string $sDefaultCharset
63 * @return self fluent interface
65 public function withDefaultCharset($sDefaultCharset)
67 $this->sDefaultCharset
= $sDefaultCharset;
72 * @param bool $bLenientParsing
74 * @return self fluent interface
76 public function withLenientParsing($bLenientParsing = true)
78 $this->bLenientParsing
= $bLenientParsing;
83 * @return self fluent interface
85 public function beStrict()
87 return $this->withLenientParsing(false);