1<?php
2/**
3* Exception thrown if a token is encountered which was not expected.
4*
5* @license http://www.opensource.org/licenses/mit-license.php The MIT License
6* @copyright Copyright 2010-2014 PhpCss Team
7*/
8
9namespace PhpCss\Exception {
10
11  use PhpCss;
12
13  /**
14  * Exception thrown if a token is encountered which was not expected.
15  */
16  class TokenMismatchException extends TokenException {
17
18    /**
19     * @param PhpCss\Scanner\Token $encounteredToken
20     * @param array $expectedTokens
21     */
22    public function __construct(PhpCss\Scanner\Token $encounteredToken, array $expectedTokens) {
23      $this->_expectedTokens = $expectedTokens;
24
25      $expectedTokenStrings = array();
26      foreach ($expectedTokens as $expectedToken) {
27        $expectedTokenStrings[] = PhpCss\Scanner\Token::typeToString($expectedToken);
28      }
29
30      parent::__construct(
31        $encounteredToken,
32       'Parse error: Found '. $encounteredToken .
33       ' while one of '.implode(", ", $expectedTokenStrings).' was expected.'
34      );
35    }
36  }
37}
38