Lexer::createTokenReader()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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