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

CodeParser   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parse() 0 3 1
A __construct() 0 6 1
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