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

ProjectorMap::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 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