AttributeMap   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 7
dl 0
loc 13
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 2
1
<?php declare(strict_types=1);
2
/**
3
 * This file is part of the daikon-cqrs/entity 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\Entity;
10
11
use Daikon\DataStructure\TypedMap;
12
use Daikon\Interop\Assertion;
13
14
final class AttributeMap extends TypedMap
15
{
16 13
    public function __construct(iterable $attributes = [])
17
    {
18 13
        $mappedAttributes = [];
19
        /** @var AttributeInterface $attribute */
20 13
        foreach ($attributes as $attribute) {
21 12
            $name = $attribute->getName();
22 12
            Assertion::keyNotExists($mappedAttributes, $name, "Attribute name '$name' is already defined.");
23 12
            $mappedAttributes[$name] = $attribute;
24
        }
25
26 12
        $this->init($mappedAttributes, [AttributeInterface::class]);
27 12
    }
28
}
29