LazyTypeByReflectionParameter::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 1
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