| @@ -1,42 +1,0 @@ | ||
| 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 | -} | |