Passed
Push — master ( ec5386...e56f88 )
by Andrey
53s queued 14s
created

ConcatService::complexity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\GraphQL\Field;
6
7
use Andi\GraphQL\Argument\Argument;
8
use Andi\GraphQL\Definition\Field\ArgumentsAwareInterface;
9
use Andi\GraphQL\Definition\Field\ComplexityAwareInterface;
10
use Andi\GraphQL\Definition\Field\ResolveAwareInterface;
11
use Andi\GraphQL\Definition\Field\TypeAwareInterface;
12
use Andi\GraphQL\Field\MutationFieldInterface;
13
use Andi\GraphQL\Field\QueryFieldInterface;
14
use GraphQL\Type\Definition as Webonyx;
15
16
final class ConcatService implements
17
    QueryFieldInterface,
18
    MutationFieldInterface,
19
    ArgumentsAwareInterface,
20
    ResolveAwareInterface,
21
    ComplexityAwareInterface
22
{
23
    public function getName(): string
24
    {
25
        return 'concat';
26
    }
27
28
    public function getDescription(): ?string
29
    {
30
        return null;
31
    }
32
33
    public function getDeprecationReason(): ?string
34
    {
35
        return null;
36
    }
37
38
    public function getType(): string
39
    {
40
        return Webonyx\StringType::class;
41
    }
42
43
    public function getMode(): int
44
    {
45
        return TypeAwareInterface::IS_REQUIRED;
46
    }
47
48
    public function getArguments(): iterable
49
    {
50
        yield [
51
            'name' => 'parts',
52
            'type' => Webonyx\Type::nonNull(
53
                Webonyx\Type::listOf(
54
                    Webonyx\Type::nonNull(
55
                        Webonyx\Type::string()
56
                    )
57
                )
58
            ),
59
        ];
60
61
        yield new Argument(
62
            name: 'separator',
63
            type: 'String',
64
            mode: TypeAwareInterface::IS_REQUIRED,
65
            defaultValue: ' ',
66
        );
67
    }
68
69
    public function resolve(mixed $objectValue, array $args, mixed $context, Webonyx\ResolveInfo $info): mixed
70
    {
71
        return implode($args['separator'], $args['parts']);
72
    }
73
74
    public function complexity(int $childrenComplexity, array $args): int
75
    {
76
        return $childrenComplexity + 1;
77
    }
78
}
79