ExampleAbstractInterfaceType   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 18
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolveType() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\GraphQL\Type;
6
7
use Andi\GraphQL\Definition\Field\TypeAwareInterface;
8
use Andi\GraphQL\Definition\Type\ResolveTypeAwareInterface;
9
use Andi\GraphQL\Type\AbstractInterfaceType;
10
use GraphQL\Type\Definition as Webonyx;
11
12
final class ExampleAbstractInterfaceType extends AbstractInterfaceType implements ResolveTypeAwareInterface
13
{
14
    protected string $name = 'ExampleAbstractInterfaceType';
15
16
    protected iterable $fields = [
17
        'lastname' => 'String',
18
        'firstname' => [
19
            'type' => 'String',
20
            'mode' => TypeAwareInterface::IS_REQUIRED,
21
            'description' => 'User firstname',
22
        ],
23
    ];
24
25
    public static function resolveType(mixed $value, mixed $context, Webonyx\ResolveInfo $info): ?string
26
    {
27
        return match (true) {
28
            $value instanceof ExampleAbstractObjectType => ExampleAbstractObjectType::class,
29
            default => null,
30
        };
31
    }
32
}
33