Completed
Push — master ( 71f966...a7254e )
by BruceScrutinizer
08:15
created

Analyser::incrementError()   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 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace NamespaceProtector;
4
5
use NamespaceProtector\Result\ResultParser;
6
use NamespaceProtector\Common\PathInterface;
7
use NamespaceProtector\Result\ResultAnalyser;
8
use NamespaceProtector\Parser\ParserInterface;
9
use NamespaceProtector\Result\ResultAnalyserInterface;
10
use NamespaceProtector\Result\ResultCollector;
11
use NamespaceProtector\Result\ResultCollectorReadable;
12
13
final class Analyser
14
{
15
    /** @var ParserInterface[]  */
16
    private $listParser;
17
18
    public function __construct(ParserInterface ...$listParser)
19
    {
20
        $this->listParser = $listParser;
21
    }
22
23
    public function execute(PathInterface $filePath): ResultAnalyserInterface
24
    {
25
        $totalParserResult = new ResultParser(new ResultCollectorReadable(new ResultCollector()));
26
        foreach ($this->listParser as $currentParser) {
27
            $result = $currentParser->parseFile($filePath);
28
            $totalParserResult = $totalParserResult->append($result);
29
        }
30
31
        return new ResultAnalyser($totalParserResult->getResultCollectionReadable());
32
    }
33
}
34