MatchSuccess   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 8
c 1
b 0
f 0
dl 0
loc 56
ccs 13
cts 13
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A shouldRepeat() 0 3 1
A __construct() 0 3 1
A hasToken() 0 3 1
A getToken() 0 3 1
A hasLexeme() 0 3 1
A getLexeme() 0 3 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