Completed
Push — master ( 9d1ab7...13f027 )
by Luis
04:13 queued 02:19
created

Php5Parser   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A buildTraverser() 0 6 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\Raw;
9
10
use PhpParser\NodeTraverser;
11
use PhpParser\ParserFactory;
12
use PhUml\Parser\Raw\Builders\Filters\MembersFilter;
13
use PhUml\Parser\Raw\Builders\RawClassBuilder;
14
use PhUml\Parser\Raw\Builders\RawInterfaceBuilder;
15
use PhUml\Parser\Raw\Visitors\ClassVisitor;
16
use PhUml\Parser\Raw\Visitors\InterfaceVisitor;
17
18
/**
19
 * It traverses the AST of all the files and interfaces found by the `CodeFinder` and builds a
20
 * `RawDefinitions` object
21
 *
22
 * In order to create the collection of raw definitions it uses two visitors
23
 *
24
 * - The `ClassVisitor` which builds `RawDefinitions` for classes
25
 * - The `InterfaceVisitor` which builds `RawDefinitions` for interfaces
26
 */
27
class Php5Parser extends PhpParser
28
{
29
    /** @param MembersFilter[] $filters */
30 96
    public function __construct(RawDefinitions $definitions = null, array $filters = [])
31
    {
32 96
        parent::__construct(
33 96
            (new ParserFactory)->create(ParserFactory::PREFER_PHP5),
34 96
            $definitions ?? new RawDefinitions(),
35 96
            $filters
36
        );
37 96
    }
38
39 96
    protected function buildTraverser(): NodeTraverser
40
    {
41 96
        $traverser = new NodeTraverser();
42 96
        $traverser->addVisitor(new ClassVisitor($this->definitions, new RawClassBuilder($this->filters)));
43 96
        $traverser->addVisitor(new InterfaceVisitor($this->definitions, new RawInterfaceBuilder($this->filters)));
44 96
        return $traverser;
45
    }
46
}
47