Compiler   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 8
dl 0
loc 21
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A compile() 0 5 1
A __construct() 0 4 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