Passed
Push — master ( 727e47...43dde9 )
by Nico
01:35
created

ParserException::forbiddenMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
/**
4
 * @license     http://opensource.org/licenses/mit-license.php MIT
5
 * @link        https://github.com/nicoSWD
6
 * @author      Nicolas Oelgart <[email protected]>
7
 */
8
namespace nicoSWD\Rule\Parser\Exception;
9
10
use nicoSWD\Rule\TokenStream\Token\BaseToken;
11
12
class ParserException extends \Exception
13
{
14 16
    public static function unexpectedToken(BaseToken $token): self
15
    {
16 16
        return new self(sprintf('Unexpected "%s" at position %d', $token->getValue(), $token->getOffset()));
17
    }
18
19 6
    public static function unknownToken(BaseToken $token): self
20
    {
21 6
        return new self(sprintf('Unknown token "%s" at position %d', $token->getValue(), $token->getOffset()));
22
    }
23
24 2
    public static function incompleteExpression(BaseToken $token): self
25
    {
26 2
        return new self(sprintf('Incomplete expression for token "%s"', $token->getValue()));
27
    }
28
29 6
    public static function undefinedVariable(string $name, BaseToken $token): self
30
    {
31 6
        return new self(sprintf('Undefined variable "%s" at position %d', $name, $token->getOffset()));
32
    }
33
34 10
    public static function undefinedMethod(string $name, BaseToken $token): self
35
    {
36 10
        return new self(sprintf('Undefined method "%s" at position %d', $name, $token->getOffset()));
37
    }
38
39 30
    public static function forbiddenMethod(string $name, BaseToken $token): self
40
    {
41 30
        return new self(sprintf('Forbidden method "%s" at position %d', $name, $token->getOffset()));
42
    }
43
44 6
    public static function undefinedFunction(string $name, BaseToken $token): self
45
    {
46 6
        return new self(sprintf('%s is not defined at position %d', $name, $token->getOffset()));
47
    }
48
49 8
    public static function unexpectedComma(BaseToken $token): self
50
    {
51 8
        return new self(sprintf('Unexpected "," at position %d', $token->getOffset()));
52
    }
53
}
54