Passed
Pull Request — master (#45)
by Andrey
13:21
created

SquaringService::getArguments()   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 0
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\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