Issue90Schema::build()   A
last analyzed

Complexity

Conditions 3
Paths 1

Size

Total Lines 46

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 46
rs 9.1781
c 0
b 0
f 0
cc 3
nc 1
nop 1
1
<?php
2
namespace Youshido\Tests\Issues\Issue90;
3
4
use Youshido\GraphQL\Config\Schema\SchemaConfig;
5
use Youshido\GraphQL\Schema\AbstractSchema;
6
use Youshido\GraphQL\Type\Object\ObjectType;
7
use Youshido\GraphQL\Type\Scalar\DateTimeType;
8
9
class Issue90Schema extends AbstractSchema
10
{
11
12
    public function build(SchemaConfig $config)
13
    {
14
        $config->setQuery(
15
            new ObjectType([
16
                'name'   => 'QueryType',
17
                'fields' => [
18
                    'echo' => [
19
                        'type'    => new DateTimeType('Y-m-d H:ia'),
20
                        'args'    => [
21
                            'date' => new DateTimeType('Y-m-d H:ia')
22
                        ],
23
                        'resolve' => function ($value, $args, $info) {
0 ignored issues
show
Unused Code introduced by
The parameter $info is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
24
25
                            if (isset($args['date'])) {
26
                                return $args['date'];
27
                            }
28
29
                            return null;
30
                        }
31
                    ]
32
                ]
33
            ])
34
        );
35
36
        $config->setMutation(
37
            new ObjectType([
38
                'name'   => 'MutationType',
39
                'fields' => [
40
                    'echo' => [
41
                        'type'    => new DateTimeType('Y-m-d H:ia'),
42
                        'args'    => [
43
                            'date' => new DateTimeType('Y-m-d H:ia')
44
                        ],
45
                        'resolve' => function ($value, $args, $info) {
0 ignored issues
show
Unused Code introduced by
The parameter $info is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
46
47
                            if (isset($args['date'])) {
48
                                return $args['date'];
49
                            }
50
51
                            return null;
52
                        }
53
                    ]
54
                ]
55
            ])
56
        );
57
    }
58
59
}