MatchFail::shouldRepeat()   A
last analyzed

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 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
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
     * @psalm-var array<int,int>
19
     */
20
    private $offsets;
21
22 10
    public function __construct(int ...$offsets)
23
    {
24 10
        $this->offsets = $offsets;
25 10
    }
26
27
    /**
28
     * @return bool
29
     * @psalm-pure
30
     */
31 1
    public function shouldRepeat(): bool
32
    {
33 1
        return false;
34
    }
35
36
    /**
37
     * @return bool
38
     * @psalm-pure
39
     */
40 1
    public function hasToken(): bool
41
    {
42 1
        return false;
43
    }
44
45
    /**
46
     * @return TokenInterface
47
     * @psalm-pure
48
     */
49 1
    public function getToken(): TokenInterface
50
    {
51 1
        throw new Exception\TokenNotMatchedException($this->offsets);
52
    }
53
54
    /**
55
     * @return bool
56
     * @psalm-pure
57
     */
58 1
    public function hasLexeme(): bool
59
    {
60 1
        return true;
61
    }
62
63
    /**
64
     * @return LexemeInterface
65
     * @psalm-pure
66
     */
67 6
    public function getLexeme(): LexemeInterface
68
    {
69 6
        return EmptyLexeme::fromOffsets(...$this->offsets);
70
    }
71
}
72