ArgumentConfigurationMiddleware   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 10 5
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Andi\GraphQL\ArgumentResolver\Middleware;
6
7
use Andi\GraphQL\ArgumentResolver\ArgumentResolverInterface;
8
use GraphQL\Type\Definition as Webonyx;
9
10
final class ArgumentConfigurationMiddleware implements MiddlewareInterface
11
{
12
    public const PRIORITY = 1024;
13
14 4
    public function process(mixed $argument, ArgumentResolverInterface $argumentResolver): array
15
    {
16 4
        $isConfig = \is_array($argument)
17 4
            && isset($argument['name'], $argument['type'])
18 4
            && \is_string($argument['name'])
19 4
            && $argument['type'] instanceof Webonyx\Type;
20
21 4
        return $isConfig
22 1
            ? $argument
23 4
            : $argumentResolver->resolve($argument);
24
    }
25
}
26