Completed
Push — master ( 88ff28...2dc58f )
by Kirill
06:03
created

Result   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 1
dl 0
loc 86
ccs 0
cts 30
cp 0
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A tokensResolver() 0 4 1
A rulesResolver() 0 4 1
A pragmasResolver() 0 4 1
A getRuntime() 0 4 1
A getParser() 0 4 1
A getLexer() 0 4 1
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\Reader;
11
12
use Railt\Compiler\Reader\Analyzer\GrammarAnalyzer;
13
use Railt\Compiler\Reader\Resolver\PragmaResolver;
14
use Railt\Compiler\Reader\Resolver\RuleResolver;
15
use Railt\Compiler\Reader\Resolver\TokenResolver;
16
use Railt\Lexer\LexerInterface;
17
use Railt\Parser\ParserInterface;
18
19
/**
20
 * Class Result
21
 */
22
class Result
23
{
24
    /**
25
     * @var Analyzer\Analyzer[]
26
     */
27
    private const RULE_ANALYZERS = [
28
        GrammarAnalyzer::class
29
    ];
30
31
    /**
32
     * @var PragmaResolver
33
     */
34
    private $pragmas;
35
36
    /**
37
     * @var TokenResolver
38
     */
39
    private $tokens;
40
41
    /**
42
     * @var RuleResolver
43
     */
44
    private $rules;
45
46
    /**
47
     * Result constructor.
48
     * @param PragmaResolver $pragmas
49
     * @param TokenResolver $tokens
50
     * @param RuleResolver $rules
51
     */
52
    public function __construct(PragmaResolver $pragmas, TokenResolver $tokens, RuleResolver $rules)
53
    {
54
        $this->pragmas = $pragmas;
55
        $this->tokens  = $tokens;
56
        $this->rules   = $rules;
57
    }
58
59
    /**
60
     * @return TokenResolver
61
     */
62
    public function tokensResolver(): TokenResolver
63
    {
64
        return $this->tokens;
65
    }
66
67
    /**
68
     * @return RuleResolver
69
     */
70
    public function rulesResolver(): RuleResolver
71
    {
72
        return $this->rules;
73
    }
74
75
    /**
76
     * @return PragmaResolver
77
     */
78
    public function pragmasResolver(): PragmaResolver
79
    {
80
        return $this->pragmas;
81
    }
82
83
    /**
84
     * @return Runtime
85
     */
86
    public function getRuntime(): Runtime
87
    {
88
        return new Runtime($this);
89
    }
90
91
    /**
92
     * @return ParserInterface
93
     * @throws \InvalidArgumentException
94
     */
95
    public function getParser(): ParserInterface
96
    {
97
        return $this->getRuntime()->getParser();
98
    }
99
100
    /**
101
     * @return LexerInterface
102
     */
103
    public function getLexer(): LexerInterface
104
    {
105
        return $this->getRuntime()->getLexer();
106
    }
107
}
108