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

RegistrationRequest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 24
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A parseValue() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\GraphQL\Type;
6
7
use Andi\GraphQL\Definition\Field\TypeAwareInterface;
8
use Andi\GraphQL\Definition\Type\ParseValueAwareInterface;
9
use Andi\GraphQL\Type\AbstractInputObjectType;
10
use GraphQL\Type\Definition\StringType;
11
12
final class RegistrationRequest extends AbstractInputObjectType implements ParseValueAwareInterface
13
{
14
    protected string $name = 'RegistrationRequest';
15
16
    protected iterable $fields = [
17
        'lastname' => 'String',
18
        'firstname' => [
19
            'type' => StringType::class,
20
            'mode' => TypeAwareInterface::IS_REQUIRED,
21
        ],
22
        'middlename' => [
23
            'type' => 'String',
24
            'defaultValue' => null,
25
        ],
26
    ];
27
28
    public static function parseValue(array $values): object
29
    {
30
        $object = new \stdClass();
31
        $object->lastname = $values['lastname'] ?? 'Smith';
32
        $object->firstname = $values['firstname'];
33
        $object->middlename = $values['middlename'] ?? 'junior';
34
35
        return $object;
36
    }
37
}
38