Compiler::compile()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Annotations\Parser;
6
7
use Doctrine\Annotations\Parser\Ast\Annotations;
8
use Doctrine\Annotations\Parser\Visitor\AstBuilder;
9
use Hoa\Compiler\Llk\Llk;
10
use Hoa\Compiler\Llk\Parser;
11
use Hoa\File\Read;
12
13
/**
14
 * @internal
15
 */
16
final class Compiler
17
{
18
    private const ROOT_NODE = Nodes::ANNOTATIONS;
19
20
    /** @var Parser */
21
    private $parser;
22
23
    /** @var AstBuilder */
24
    private $visitor;
25
26 29
    public function __construct()
27
    {
28 29
        $this->parser  = Llk::load(new Read(__DIR__ . '/grammar.pp'));
29 29
        $this->visitor = new AstBuilder();
30 29
    }
31
32 29
    public function compile(string $docblock) : Annotations
33
    {
34 29
        $tree = $this->parser->parse($docblock, self::ROOT_NODE);
35
36 29
        return $this->visitor->visit($tree);
37
    }
38
}
39