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

Php5Parser::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 1
rs 9.4285
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\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