PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.0.2
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.0.2
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
acymailing / back / Libraries / Sabberworm / CSS / src / Parser.php

Parser.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 11.0.2, at back/Libraries/Sabberworm/CSS/src/Parser.php

43 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace AcyMailing\Libraries\Sabberworm\CSS;
6
7 use AcyMailing\Libraries\Sabberworm\CSS\CSSList\Document;
8 use AcyMailing\Libraries\Sabberworm\CSS\Parsing\ParserState;
9 use AcyMailing\Libraries\Sabberworm\CSS\Parsing\SourceException;
10
11 /**
12 * This class parses CSS from text into a data structure.
13 */
14 class Parser
15 {
16 /**
17 * @var ParserState
18 */
19 private $parserState;
20
21 /**
22 * @param string $text the complete CSS as text (i.e., usually the contents of a CSS file)
23 * @param int<1, max> $lineNumber the line number (starting from 1, not from 0)
24 */
25 public function __construct(string $text, ?Settings $parserSettings = null, int $lineNumber = 1)
26 {
27 if ($parserSettings === null) {
28 $parserSettings = Settings::create();
29 }
30 $this->parserState = new ParserState($text, $parserSettings, $lineNumber);
31 }
32
33 /**
34 * Parses the CSS provided to the constructor and creates a `Document` from it.
35 *
36 * @throws SourceException
37 */
38 public function parse(): Document
39 {
40 return Document::parse($this->parserState);
41 }
42 }
43