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

Parser::bootGrammar()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 368

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 366
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 368
ccs 366
cts 366
cp 1
crap 1
rs 8
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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