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

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