ArgumentConfigurationMiddleware::process()   A
last analyzed

Complexity

Conditions 5
Paths 8

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 5

Importance

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