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

EventProjector::matches()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 9
ccs 0
cts 9
cp 0
crap 12
rs 10
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\EventSourcing\Aggregate\Event\DomainEventInterface;
12
13
final class EventProjector implements EventProjectorInterface
14
{
15
    private array $eventExpressions;
16
17
    private ProjectorInterface $projector;
18
19
    public function __construct(array $eventExpressions, ProjectorInterface $projector)
20
    {
21
        $this->eventExpressions = $eventExpressions;
22
        $this->projector = $projector;
23
    }
24
25
    public function matches(DomainEventInterface $event): bool
26
    {
27
        $eventFqcn = get_class($event);
28
        foreach ($this->eventExpressions as $eventExpression) {
29
            if ($eventExpression === $eventFqcn) {
30
                return true;
31
            }
32
        }
33
        return false;
34
    }
35
36
    public function getProjector(): ProjectorInterface
37
    {
38
        return $this->projector;
39
    }
40
41
    public function getEventExpressions(): array
42
    {
43
        return $this->eventExpressions;
44
    }
45
}
46