Test Failed
Push — master ( 33bfdc...47f867 )
by Kirill
02:32
created

Parser::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of Railt package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Railt\SDL\Frontend;
11
12
/**
13
 * Class Parser
14
 */
15
final class Parser extends BaseParser
16
{
17
    /**
18
     * Make tokens public
19
     * @var string[]
20
     */
21
    public const LEXER_TOKENS = parent::LEXER_TOKENS;
22
23
    /**
24
     * @param string $lexeme
25
     * @return string
26
     */
27
    public static function pattern(string $lexeme): string
28
    {
29
        return \sprintf('/^%s$/', self::LEXER_TOKENS[$lexeme]);
30
    }
31
32
    /**
33
     * @param string $lexeme
34
     * @param string $value
35
     * @return bool
36
     */
37
    public static function match(string $lexeme, string $value): bool
38
    {
39
        return (bool)\preg_match(self::pattern($lexeme), $value);
40
    }
41
}
42