MatchSuccess::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\LexemeInterface;
8
9
/**
10
 * @psalm-immutable
11
 */
12
final class MatchSuccess implements MatchResultInterface
13
{
14
15
    /**
16
     * @var TokenInterface
17
     */
18
    private $token;
19
20 5
    public function __construct(TokenInterface $token)
21
    {
22 5
        $this->token = $token;
23 5
    }
24
25
    /**
26
     * @return bool
27
     * @psalm-pure
28
     */
29 1
    public function shouldRepeat(): bool
30
    {
31 1
        return false;
32
    }
33
34
    /**
35
     * @return bool
36
     * @psalm-pure
37
     */
38 1
    public function hasToken(): bool
39
    {
40 1
        return true;
41
    }
42
43
    /**
44
     * @return TokenInterface
45
     * @psalm-pure
46
     */
47 1
    public function getToken(): TokenInterface
48
    {
49 1
        return $this->token;
50
    }
51
52
    /**
53
     * @return bool
54
     * @psalm-pure
55
     */
56 1
    public function hasLexeme(): bool
57
    {
58 1
        return true;
59
    }
60
61
    /**
62
     * @return LexemeInterface
63
     * @psalm-pure
64
     */
65 1
    public function getLexeme(): LexemeInterface
66
    {
67 1
        return $this->token->getLexeme();
68
    }
69
}
70