AbstractOuterObjectFieldByReflectionMethodMiddleware   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 23
ccs 11
cts 11
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A buildField() 0 11 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Andi\GraphQL\ObjectFieldResolver\Middleware;
6
7
use Andi\GraphQL\ArgumentResolver\ArgumentResolverInterface;
8
use Andi\GraphQL\Field\OuterObjectField;
9
use Andi\GraphQL\TypeRegistryInterface;
10
use GraphQL\Type\Definition as Webonyx;
11
use ReflectionMethod;
12
use Spiral\Attributes\ReaderInterface;
13
use Spiral\Core\InvokerInterface;
14
use Spiral\Core\ScopeInterface;
15
16
abstract class AbstractOuterObjectFieldByReflectionMethodMiddleware extends AbstractFieldByReflectionMethodMiddleware
17
{
18 7
    public function __construct(
19
        ReaderInterface $reader,
20
        TypeRegistryInterface $typeRegistry,
21
        ArgumentResolverInterface $argumentResolver,
22
        private readonly ScopeInterface $scope,
23
        private readonly InvokerInterface $invoker,
24
    ) {
25 7
        parent::__construct($reader, $typeRegistry, $argumentResolver);
26
    }
27
28 3
    protected function buildField(array $config, ReflectionMethod $method): Webonyx\FieldDefinition
29
    {
30 3
        $config['args'] = \iterator_to_array($iterator = $this->getFieldArguments($method));
31
32 3
        return new OuterObjectField(
33 3
            $config,
34 3
            $method->getDeclaringClass()->getName(),
35 3
            $method->getName(),
36 3
            $iterator->getReturn(),
37 3
            $this->scope,
38 3
            $this->invoker,
39 3
        );
40
    }
41
}
42