Failed Conditions
Pull Request — new-parser-ast-metadata (#2)
by
unknown
02:08
created

Instantiator::instantiate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Annotations\Constructor\Instantiator;
6
7
use Doctrine\Annotations\Metadata\AnnotationMetadata;
8
9
final class Instantiator
10
{
11
    /** @var ConstructorInstantiatorStrategy */
12
    private $constructor;
13
14
    /** @var PropertyInstantiatorStrategy */
15
    private $property;
16
17 9
    public function __construct(ConstructorInstantiatorStrategy $constructor, PropertyInstantiatorStrategy $property)
18
    {
19 9
        $this->constructor = $constructor;
20 9
        $this->property    = $property;
21 9
    }
22
23 9
    public function instantiate(AnnotationMetadata $metadata, iterable $parameters) : object
24
    {
25 9
        if ($metadata->hasConstructor()) {
26 6
            return $this->constructor->construct($metadata, $parameters);
0 ignored issues
show
Bug introduced by
$parameters of type iterable is incompatible with the type array expected by parameter $parameters of Doctrine\Annotations\Con...orStrategy::construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

26
            return $this->constructor->construct($metadata, /** @scrutinizer ignore-type */ $parameters);
Loading history...
27
        }
28
29 9
        return $this->property->construct($metadata, $parameters);
0 ignored issues
show
Bug introduced by
$parameters of type iterable is incompatible with the type array expected by parameter $parameters of Doctrine\Annotations\Con...orStrategy::construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

29
        return $this->property->construct($metadata, /** @scrutinizer ignore-type */ $parameters);
Loading history...
30
    }
31
}
32