Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]

   1  <?php
   2  
   3  namespace Sabberworm\CSS;
   4  
   5  use Sabberworm\CSS\Rule\Rule;
   6  
   7  /**
   8   * Parser settings class.
   9   *
  10   * Configure parser behaviour here.
  11   */
  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.
  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  }