Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 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 39 and 401] [Versions 39 and 402] [Versions 39 and 403]

   1  <?php
   2  
   3  namespace Sabberworm\CSS;
   4  
   5  use Sabberworm\CSS\CSSList\Document;
   6  use Sabberworm\CSS\Parsing\ParserState;
   7  
   8  /**
   9   * Parser class parses CSS from text into a data structure.
  10   */
  11  class Parser {
  12  	 private $oParserState;
  13  
  14  	 /**
  15  	  * Parser constructor.
  16  	  * Note that that iLineNo starts from 1 and not 0
  17  	  *
  18  	  * @param $sText
  19  	  * @param Settings|null $oParserSettings
  20  	  * @param int $iLineNo
  21  	  */
  22  	public function __construct($sText, Settings $oParserSettings = null, $iLineNo = 1) {
  23  	 	 if ($oParserSettings === null) {
  24  	 	 	 $oParserSettings = Settings::create();
  25  	 	 }
  26  	 	 $this->oParserState = new ParserState($sText, $oParserSettings, $iLineNo);
  27  	 }
  28  
  29  	public function setCharset($sCharset) {
  30  	 	 $this->oParserState->setCharset($sCharset);
  31  	 }
  32  
  33  	public function getCharset() {
  34  	 	 $this->oParserState->getCharset();
  35  	 }
  36  
  37  	public function parse() {
  38  	 	 return Document::parse($this->oParserState);
  39  	 }
  40  
  41  }