Issues (142)

Report.php (1 issue)

Labels
Severity
1
<?php
2
3
/*
4
 * This file is part of the doyo/code-coverage project.
5
 *
6
 * (c) Anthonius Munthi <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Doyo\Bridge\CodeCoverage;
15
16
use Doyo\Bridge\CodeCoverage\Event\CoverageEvent;
17
use Doyo\Bridge\CodeCoverage\Report\ReportProcessorInterface;
18
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
0 ignored issues
show
The type Symfony\Component\EventD...ventSubscriberInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
20
class Report implements EventSubscriberInterface
21
{
22
    /**
23
     * @var ReportProcessorInterface[]
24
     */
25
    private $processors = [];
26
27
    public static function getSubscribedEvents()
28
    {
29
        return [
30
            CoverageEvent::report => 'generate',
31
        ];
32
    }
33
34
    /**
35
     * @return ReportProcessorInterface[]
36
     */
37
    public function getProcessors(): array
38
    {
39
        return $this->processors;
40
    }
41
42
    public function addProcessor(ReportProcessorInterface $processor)
43
    {
44
        $type = $processor->getType();
45
        if (!$this->hasProcessor($type)) {
46
            $this->processors[$type] = $processor;
47
        }
48
    }
49
50
    public function hasProcessor(string $type): bool
51
    {
52
        return isset($this->processors[$type]);
53
    }
54
55
    public function generate(CoverageEvent $event)
56
    {
57
        $consoleIO = $event->getConsoleIO();
58
        $processor = $event->getProcessor();
59
60
        $consoleIO->coverageSection('processing code coverage reports');
61
62
        foreach ($this->processors as $reportProcessor) {
63
            $reportProcessor->process($processor, $consoleIO);
64
        }
65
    }
66
}
67