Merge branch 'MDL-73076-master' of https://github.com/lameze/moodle
[moodle.git] / lib / php-css-parser / Parser.php
blob2520cb34907044fec94a4db220a63b5012064b75
1 <?php
3 namespace Sabberworm\CSS;
5 use Sabberworm\CSS\CSSList\Document;
6 use Sabberworm\CSS\Parsing\ParserState;
8 /**
9 * Parser class parses CSS from text into a data structure.
11 class Parser {
12 private $oParserState;
14 /**
15 * Parser constructor.
16 * Note that that iLineNo starts from 1 and not 0
18 * @param $sText
19 * @param Settings|null $oParserSettings
20 * @param int $iLineNo
22 public function __construct($sText, Settings $oParserSettings = null, $iLineNo = 1) {
23 if ($oParserSettings === null) {
24 $oParserSettings = Settings::create();
26 $this->oParserState = new ParserState($sText, $oParserSettings, $iLineNo);
29 public function setCharset($sCharset) {
30 $this->oParserState->setCharset($sCharset);
33 public function getCharset() {
34 $this->oParserState->getCharset();
37 public function parse() {
38 return Document::parse($this->oParserState);