Completed
Push — master ( 69b695...671bd7 )
by Kirill
06:49
created

Reader::lex()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 22
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
dl 0
loc 22
c 0
b 0
f 0
ccs 0
cts 18
cp 0
rs 8.6737
cc 5
eloc 12
nc 5
nop 1
crap 30
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\Compiler;
11
12
use Railt\Compiler\Reader\GrammarInterface;
13
use Railt\Compiler\Reader\Result;
14
use Railt\Io\Readable;
15
16
/**
17
 * Class Reader
18
 */
19
class Reader implements GrammarInterface
20
{
21
    /**
22
     * @var GrammarInterface
23
     */
24
    private $grammar;
25
26
    /**
27
     * Reader constructor.
28
     * @param string $language
29
     */
30
    public function __construct(string $language)
31
    {
32
        \assert(\is_subclass_of($language, GrammarInterface::class));
0 ignored issues
show
Bug introduced by
Due to PHP Bug #53727, is_subclass_of might return inconsistent results on some PHP versions if \Railt\Compiler\Reader\GrammarInterface::class can be an interface. If so, you could instead use ReflectionClass::implementsInterface.
Loading history...
33
34
        $this->grammar = new $language;
35
    }
36
37
    /**
38
     * @param Readable $input
39
     * @return GrammarInterface
40
     */
41
    public function add(Readable $input): GrammarInterface
42
    {
43
        return $this->grammar->add($input);
44
    }
45
46
    /**
47
     * @return Result
48
     */
49
    public function make(): Result
50
    {
51
        return $this->grammar->make();
52
    }
53
}
54