# acymailing/trunk/back/Libraries/Sabberworm/CSS/src/Parser.php

AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress, version trunk. 43 lines.

- Page: https://pluginprobe.com/plugins/acymailing/trunk/code/back/Libraries/Sabberworm/CSS/src/Parser.php
- Raw: https://pluginprobe.com/plugins/acymailing/trunk/raw/back/Libraries/Sabberworm/CSS/src/Parser.php
- Modified: 2026-06-09T07:53:26+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/acymailing/trunk/code/back/Libraries/Sabberworm/CSS/src/Parser.php#L10-L20`.

```php
<?php

declare(strict_types=1);

namespace AcyMailing\Libraries\Sabberworm\CSS;

use AcyMailing\Libraries\Sabberworm\CSS\CSSList\Document;
use AcyMailing\Libraries\Sabberworm\CSS\Parsing\ParserState;
use AcyMailing\Libraries\Sabberworm\CSS\Parsing\SourceException;

/**
 * This class parses CSS from text into a data structure.
 */
class Parser
{
    /**
     * @var ParserState
     */
    private $parserState;

    /**
     * @param string $text the complete CSS as text (i.e., usually the contents of a CSS file)
     * @param int<1, max> $lineNumber the line number (starting from 1, not from 0)
     */
    public function __construct(string $text, ?Settings $parserSettings = null, int $lineNumber = 1)
    {
        if ($parserSettings === null) {
            $parserSettings = Settings::create();
        }
        $this->parserState = new ParserState($text, $parserSettings, $lineNumber);
    }

    /**
     * Parses the CSS provided to the constructor and creates a `Document` from it.
     *
     * @throws SourceException
     */
    public function parse(): Document
    {
        return Document::parse($this->parserState);
    }
}

```
