Lexer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 23
ccs 5
cts 5
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createTokenReader() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Remorhaz\Lexer\Runtime;
6
7
use Remorhaz\Lexer\Runtime\IO\PreviewBuffer;
8
use Remorhaz\Lexer\Runtime\IO\SymbolReaderInterface;
9
use Remorhaz\Lexer\Runtime\Token\MatcherSelectorInterface;
10
use Remorhaz\Lexer\Runtime\Token\TokenReader;
11
use Remorhaz\Lexer\Runtime\Token\TokenReaderInterface;
12
13
final class Lexer implements LexerInterface
14
{
15
16
    /**
17
     * @var MatcherSelectorInterface
18
     */
19
    private $matcherSelector;
20
21
    /**
22
     * @param MatcherSelectorInterface $matcherSelector
23
     */
24 3
    public function __construct(MatcherSelectorInterface $matcherSelector)
25
    {
26 3
        $this->matcherSelector = $matcherSelector;
27 3
    }
28
29
    /**
30
     * @param SymbolReaderInterface $input
31
     * @return TokenReaderInterface
32
     */
33 3
    public function createTokenReader(SymbolReaderInterface $input): TokenReaderInterface
34
    {
35 3
        return new TokenReader(new PreviewBuffer($input), clone $this->matcherSelector);
36
    }
37
}
38