Completed
Push — master ( b54cbd...d09870 )
by Luis
18:59
created

CodeParser::parse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * PHP version 7.1
4
 *
5
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
6
 */
7
8
namespace PhUml\Parser;
9
10
use PhUml\Code\Structure;
11
use PhUml\Parser\Raw\TokenParser;
12
13
/**
14
 * It takes the files found by the `CodeFinder` and turns the into a code `Structure`
15
 *
16
 * A code `Structure` is a collection of `Definition`s (classes and interfaces)
17
 */
18
class CodeParser
19
{
20
    /** @var StructureBuilder */
21
    private $builder;
22
23
    /** @var TokenParser */
24
    private $parser;
25
26
    public function __construct(
27
        StructureBuilder $builder = null,
28
        TokenParser $parser = null
29
    ) {
30
        $this->builder = $builder ?? new StructureBuilder();
31
        $this->parser = $parser ?? new TokenParser();
32
    }
33
34
    public function parse(CodeFinder $finder): Structure
35
    {
36
        return $this->builder->buildFrom($this->parser->parse($finder));
37
    }
38
}
39