ConstructorInstantiatorStrategy   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A construct() 0 12 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Annotations\Constructor\Instantiator;
6
7
use Doctrine\Annotations\Metadata\AnnotationMetadata;
8
use function array_key_exists;
9
use function assert;
10
11
final class ConstructorInstantiatorStrategy implements InstantiatorStrategy
12
{
13
    /**
14
     * @param mixed[] $parameters array<string, mixed>
15
     */
16 6
    public function construct(AnnotationMetadata $metadata, array $parameters) : object
17
    {
18 6
        if (array_key_exists(null, $parameters)) {
19 6
            $defaultProperty = $metadata->getDefaultProperty();
20 6
            assert($defaultProperty !== null);
21
22 6
            $parameters['value'] = $parameters[null];
23 6
            unset($parameters[null]);
24
        }
25
26 6
        $class = $metadata->getName();
27 6
        return new $class($parameters);
28
    }
29
}
30