Passed
Push — master ( d25e4d...dba989 )
by Mr
06:54
created

AttributeMap   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 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 Assert\Assert;
12
use Daikon\DataStructure\TypedMapInterface;
13
use Daikon\DataStructure\TypedMapTrait;
0 ignored issues
show
Bug introduced by
The type Daikon\DataStructure\TypedMapTrait was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
15
final class AttributeMap implements TypedMapInterface
16
{
17
    use TypedMapTrait;
18
19 13
    public function __construct(iterable $attributes = [])
20
    {
21 13
        $mappedAttributes = [];
22
        /** @var AttributeInterface $attribute */
23 13
        foreach ($attributes as $attribute) {
24 12
            $attributeName = $attribute->getName();
25 12
            Assert::that($mappedAttributes)->keyNotExists(
26 12
                $attributeName,
27 12
                "Attribute name '$attributeName' is already defined."
28
            );
29 12
            $mappedAttributes[$attributeName] = $attribute;
30
        }
31
32 12
        $this->init($mappedAttributes, [AttributeInterface::class]);
33 12
    }
34
}
35