Test Failed
Push — master ( deb397...eab8d5 )
by Mr
01:40
created

ProjectorMap   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 17
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A filterByAggregatePrefix() 0 7 1
1
<?php
2
3
namespace Daikon\Dbal\Projector;
4
5
use Daikon\Cqrs\Aggregate\AggregatePrefix;
6
use Daikon\DataStructures\TypedMapTrait;
7
8
final class ProjectorMap implements \IteratorAggregate, \Countable
9
{
10
    use TypedMapTrait;
11
12
    public function __construct(array $projectors = [])
13
    {
14
        $this->init($projectors, ProjectorInterface::class);
15
    }
16
17
    public function filterByAggregatePrefix(AggregatePrefix $aggregatePrefix)
18
    {
19
        $prefix = $aggregatePrefix->toNative();
20
        return $this->compositeMap->filter(function ($key) use ($prefix) {
21
            return strpos($key, $prefix) === 0;
22
        });
23
    }
24
}
25