ListProjectors   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 28
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 5 1
A execute() 0 10 2
A __construct() 0 5 1
1
<?php declare(strict_types=1);
2
/**
3
 * This file is part of the daikon-cqrs/boot project.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace Daikon\Boot\Console\Command;
10
11
use Daikon\ReadModel\Projector\EventProjectorMap;
12
use Symfony\Component\Console\Command\Command;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Console\Command\Command 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...
13
use Symfony\Component\Console\Input\InputInterface;
14
use Symfony\Component\Console\Output\OutputInterface;
15
16
final class ListProjectors extends Command
17
{
18
    private EventProjectorMap $eventProjectorMap;
19
20
    public function __construct(EventProjectorMap $eventProjectorMap)
21
    {
22
        $this->eventProjectorMap = $eventProjectorMap;
23
24
        parent::__construct();
25
    }
26
27
    protected function configure(): void
28
    {
29
        $this
30
            ->setName('projector:ls')
31
            ->setDescription('Lists currently configured projectors.');
32
    }
33
34
    protected function execute(InputInterface $input, OutputInterface $output): int
35
    {
36
        foreach ($this->eventProjectorMap as $projectorKey => $eventProjector) {
37
            $projectorFqcn = get_class($eventProjector->getProjector());
38
            $output->writeln("Projector <options=bold>$projectorKey</> implemented by $projectorFqcn");
39
            //@todo use closure binding instead of getter on EventProjector
40
            $output->writeln('  Responds to: '.implode(" | ", $eventProjector->getEventExpressions()));
41
        }
42
43
        return 0;
44
    }
45
}
46