Passed
Push — master ( a89473...8b9f9e )
by Edward
14:25
created

MatchFail::getLexeme()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 0
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Remorhaz\Lexer\Runtime\Token;
6
7
use Remorhaz\Lexer\Runtime\IO\EmptyLexeme;
8
use Remorhaz\Lexer\Runtime\IO\LexemeInterface;
9
10
/**
11
 * @psalm-immutable
12
 */
13
final class MatchFail implements MatchResultInterface
14
{
15
16
    /**
17
     * @var int[]
18
     */
19
    private $offsets;
20
21
    public function __construct(int ...$offsets)
22
    {
23
        $this->offsets = $offsets;
24
    }
25
26
    /**
27
     * @return bool
28
     * @psalm-pure
29
     */
30
    public function shouldRepeat(): bool
31
    {
32
        return false;
33
    }
34
35
    /**
36
     * @return bool
37
     * @psalm-pure
38
     */
39
    public function hasToken(): bool
40
    {
41
        return false;
42
    }
43
44
    /**
45
     * @return TokenInterface
46
     * @psalm-pure
47
     */
48
    public function getToken(): TokenInterface
49
    {
50
        throw new Exception\TokenNotMatchedException($this->offsets);
51
    }
52
53
    /**
54
     * @return bool
55
     * @psalm-pure
56
     */
57
    public function hasLexeme(): bool
58
    {
59
        return true;
60
    }
61
62
    /**
63
     * @return LexemeInterface
64
     * @psalm-pure
65
     */
66
    public function getLexeme(): LexemeInterface
67
    {
68
        return EmptyLexeme::fromOffsets(...$this->offsets);
69
    }
70
}
71