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

SquaringService   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 14
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 3 1
A getArguments() 0 3 1
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\ResolveAwareInterface;
9
use Andi\GraphQL\Definition\Field\TypeAwareInterface;
10
use Andi\GraphQL\Field\AbstractObjectField;
11
use Andi\GraphQL\Field\QueryFieldInterface;
12
use GraphQL\Type\Definition as Webonyx;
13
14
final class SquaringService extends AbstractObjectField implements QueryFieldInterface, ResolveAwareInterface
15
{
16
    protected string $name = 'square';
17
    protected string $type = 'Int';
18
    protected int $mode = TypeAwareInterface::IS_REQUIRED;
19
20
    public function getArguments(): iterable
21
    {
22
        yield new Argument(name: 'num', type: 'Int', mode: TypeAwareInterface::IS_REQUIRED);
23
    }
24
25
    public function resolve(mixed $objectValue, array $args, mixed $context, Webonyx\ResolveInfo $info): mixed
26
    {
27
        return $args['num'] * $args['num'];
28
    }
29
}
30