LazyTypeByReflectionParameter::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 7
ccs 5
cts 5
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Andi\GraphQL\Common;
6
7
use Andi\GraphQL\TypeRegistryInterface;
8
use GraphQL\Type\Definition as Webonyx;
9
use ReflectionParameter;
10
11
final class LazyTypeByReflectionParameter extends LazyTypeByReflectionType
12
{
13 6
    public function __construct(
14
        private readonly ReflectionParameter $parameter,
15
        private readonly TypeRegistryInterface $typeRegistry,
16
    ) {
17 6
        parent::__construct(
18 6
            $this->parameter->getType(),
19 6
            $this->typeRegistry,
20 6
            $this->parameter->getDeclaringClass()->getName(),
21 6
        );
22
    }
23
24 5
    public function __invoke(): Webonyx\Type
25
    {
26 5
        $type = parent::__invoke();
27
28 5
        return $this->parameter->isVariadic()
29 1
            ? Webonyx\Type::listOf($type)
30 5
            : $type;
31
    }
32
}
33