Passed
Push — 1.5 ( c7c5a4...fe8795 )
by Luis
06:06
created

PhpParser::parse()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 2
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\Code;
9
10
use PhpParser\Parser;
11
use PhUml\Code\Codebase;
12
use PhUml\Parser\CodeFinder;
13
14
abstract class PhpParser
15
{
16
    /** @var Parser */
17
    private $parser;
18
19
    /** @var PhpTraverser */
20
    private $traverser;
21
22 129
    public function __construct(Parser $parser, PhpTraverser $traverser)
23
    {
24 129
        $this->parser = $parser;
25 129
        $this->traverser = $traverser;
26 129
    }
27
28 111
    public function parse(CodeFinder $finder): Codebase
29
    {
30 111
        foreach ($finder->files() as $code) {
31 108
            $this->traverser->traverse($this->parser->parse($code));
32
        }
33 111
        return $this->traverser->codebase();
34
    }
35
}
36