3 namespace Sabberworm\CSS\Parsing
;
6 * Thrown if the CSS parsers encounters a token it did not expect
8 class UnexpectedTokenException
extends SourceException
{
11 // Possible values: literal, identifier, count, expression, search
14 public function __construct($sExpected, $sFound, $sMatchType = 'literal', $iLineNo = 0) {
15 $this->sExpected
= $sExpected;
16 $this->sFound
= $sFound;
17 $this->sMatchType
= $sMatchType;
18 $sMessage = "Token “{$sExpected}” ({$sMatchType}) not found. Got “{$sFound}”.";
19 if($this->sMatchType
=== 'search') {
20 $sMessage = "Search for “{$sExpected}” returned no results. Context: “{$sFound}”.";
21 } else if($this->sMatchType
=== 'count') {
22 $sMessage = "Next token was expected to have {$sExpected} chars. Context: “{$sFound}”.";
23 } else if($this->sMatchType
=== 'identifier') {
24 $sMessage = "Identifier expected. Got “{$sFound}”";
25 } else if($this->sMatchType
=== 'custom') {
26 $sMessage = trim("$sExpected $sFound");
29 parent
::__construct($sMessage, $iLineNo);