mailpoet
/
vendor-prefixed
/
sabberworm
/
php-css-parser
/
src
/
Parsing
/
UnexpectedTokenException.php
Anchor.php
2 years ago
OutputException.php
4 years ago
ParserState.php
2 years ago
SourceException.php
4 years ago
UnexpectedEOFException.php
4 years ago
UnexpectedTokenException.php
4 years ago
index.php
3 years ago
UnexpectedTokenException.php
27 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Sabberworm\CSS\Parsing; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | class UnexpectedTokenException extends SourceException |
| 5 | { |
| 6 | private $sExpected; |
| 7 | private $sFound; |
| 8 | private $sMatchType; |
| 9 | public function __construct($sExpected, $sFound, $sMatchType = 'literal', $iLineNo = 0) |
| 10 | { |
| 11 | $this->sExpected = $sExpected; |
| 12 | $this->sFound = $sFound; |
| 13 | $this->sMatchType = $sMatchType; |
| 14 | $sMessage = "Token “{$sExpected}” ({$sMatchType}) not found. Got “{$sFound}”."; |
| 15 | if ($this->sMatchType === 'search') { |
| 16 | $sMessage = "Search for “{$sExpected}” returned no results. Context: “{$sFound}”."; |
| 17 | } elseif ($this->sMatchType === 'count') { |
| 18 | $sMessage = "Next token was expected to have {$sExpected} chars. Context: “{$sFound}”."; |
| 19 | } elseif ($this->sMatchType === 'identifier') { |
| 20 | $sMessage = "Identifier expected. Got “{$sFound}”"; |
| 21 | } elseif ($this->sMatchType === 'custom') { |
| 22 | $sMessage = \trim("{$sExpected} {$sFound}"); |
| 23 | } |
| 24 | parent::__construct($sMessage, $iLineNo); |
| 25 | } |
| 26 | } |
| 27 |