Passed
Push — master ( 1edf79...0bb627 )
by Mr
06:58
created

EventProjector   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 78.56%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 12
c 2
b 0
f 0
dl 0
loc 31
ccs 11
cts 14
cp 0.7856
rs 10
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getEventExpressions() 0 3 1
A __construct() 0 4 1
A getProjector() 0 3 1
A matches() 0 9 3
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 1
    public function __construct(array $eventExpressions, ProjectorInterface $projector)
20
    {
21 1
        $this->eventExpressions = $eventExpressions;
22 1
        $this->projector = $projector;
23 1
    }
24
25 1
    public function matches(DomainEventInterface $event): bool
26
    {
27 1
        $eventFqcn = get_class($event);
28 1
        foreach ($this->eventExpressions as $eventExpression) {
29 1
            if ($eventExpression === $eventFqcn) {
30 1
                return true;
31
            }
32
        }
33
        return false;
34
    }
35
36 1
    public function getProjector(): ProjectorInterface
37
    {
38 1
        return $this->projector;
39
    }
40
41
    public function getEventExpressions(): array
42
    {
43
        return $this->eventExpressions;
44
    }
45
}
46