AbstractObjectFieldByReflectionMethodMiddleware   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A buildField() 0 10 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\ObjectField;
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
/**
17
 * @see Webonyx\FieldDefinition
18
 *
19
 * @phpstan-import-type FieldDefinitionConfig from Webonyx\FieldDefinition
20
 */
21
abstract class AbstractObjectFieldByReflectionMethodMiddleware extends AbstractFieldByReflectionMethodMiddleware
22
{
23 7
    public function __construct(
24
        ReaderInterface $reader,
25
        TypeRegistryInterface $typeRegistry,
26
        ArgumentResolverInterface $argumentResolver,
27
        private readonly ScopeInterface $scope,
28
        private readonly InvokerInterface $invoker,
29
    ) {
30 7
        parent::__construct($reader, $typeRegistry, $argumentResolver);
31
    }
32
33
    /**
34
     * @param FieldDefinitionConfig $config
0 ignored issues
show
Bug introduced by
The type Andi\GraphQL\ObjectField...e\FieldDefinitionConfig was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
35
     * @param ReflectionMethod $method
36
     *
37
     * @return Webonyx\FieldDefinition
38
     */
39 3
    protected function buildField(array $config, ReflectionMethod $method): Webonyx\FieldDefinition
40
    {
41 3
        $config['args'] = \iterator_to_array($iterator = $this->getFieldArguments($method));
42
43 3
        return new ObjectField(
44 3
            $config,
45 3
            $method->getName(),
46 3
            $iterator->getReturn(),
47 3
            $this->scope,
48 3
            $this->invoker,
49 3
        );
50
    }
51
}
52