ParseException   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A unexpected() 0 10 1
1
<?php
2
/**
3
 * This file is part of PHP-Yacc package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace PhpYacc\Exception;
11
12
use PhpYacc\Yacc\Token;
13
14
/**
15
 * Class ParseException.
16
 */
17
class ParseException extends PhpYaccException
18
{
19
    /**
20
     * @param Token $token
21
     * @param $expecting
22
     *
23
     * @return ParseException
24
     */
25
    public static function unexpected(Token $token, $expecting): self
26
    {
27
        $fileName = $token->getFilename();
28
        $line = $token->getLine();
29
30
        return new self(\sprintf(
31
            'Unexpected %s, expecting %s at %s:%d',
32
            Token::decode($token->getType()), Token::decode($expecting), $fileName, $line
33
        ));
34
    }
35
}
36