Passed
Push — master ( 2279c5...1edf79 )
by Mr
06:36
created

EventProjectorMap   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 18
ccs 0
cts 13
cp 0
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A findFor() 0 9 3
A __construct() 0 3 1
1
<?php declare(strict_types=1);
2
/**
3
 * This file is part of the daikon-cqrs/read-model 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\ReadModel\Projector;
10
11
use Daikon\DataStructure\TypedMapInterface;
12
use Daikon\DataStructure\TypedMapTrait;
0 ignored issues
show
Bug introduced by
The type Daikon\DataStructure\TypedMapTrait 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 Daikon\EventSourcing\Aggregate\Event\DomainEventInterface;
14
15
final class EventProjectorMap implements TypedMapInterface
16
{
17
    use TypedMapTrait;
18
19
    public function __construct(iterable $eventProjectors = [])
20
    {
21
        $this->init($eventProjectors, [EventProjectorInterface::class]);
22
    }
23
24
    public function findFor(DomainEventInterface $event): ProjectorMap
25
    {
26
        $projectors = [];
27
        foreach ($this as $projectorKey => $eventProjector) {
28
            if ($eventProjector->matches($event)) {
29
                $projectors[$projectorKey] = $eventProjector->getProjector();
30
            }
31
        }
32
        return new ProjectorMap($projectors);
33
    }
34
}
35