3 namespace Sabberworm\CSS
;
5 use Sabberworm\CSS\Rule\Rule
;
8 * Parser settings class.
10 * Configure parser behaviour here.
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;
19 * The default charset for the CSS if no `@charset` rule is found. Defaults to utf-8.
21 public $sDefaultCharset = 'utf-8';
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;
41 public function withDefaultCharset($sDefaultCharset) {
42 $this->sDefaultCharset
= $sDefaultCharset;
46 public function withLenientParsing($bLenientParsing = true) {
47 $this->bLenientParsing
= $bLenientParsing;
51 public function beStrict() {
52 return $this->withLenientParsing(false);