Completed
Pull Request — master (#13)
by
unknown
05:06
created

TestObjectType::build()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 41
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
c 5
b 0
f 0
dl 0
loc 41
rs 8.8571
cc 1
eloc 25
nc 1
nop 1
1
<?php
2
/*
3
* This file is a part of graphql-youshido project.
4
*
5
* @author Alexandr Viniychuk <[email protected]>
6
* created: 11/30/15 12:44 AM
7
*/
8
9
namespace Youshido\Tests\DataProvider;
10
11
use Youshido\GraphQL\Type\Object\AbstractObjectType;
12
use Youshido\GraphQL\Type\Object\ObjectType;
13
use Youshido\GraphQL\Type\Scalar\IntType;
14
use Youshido\GraphQL\Type\Scalar\StringType;
15
use Youshido\GraphQL\Type\NonNullType;
16
17
class TestObjectType extends AbstractObjectType
18
{
19
20
    public function build($config)
21
    {
22
        $config
23
            ->addField('id', new IntType())
24
            ->addField('name', new StringType())
25
            ->addField('region', new ObjectType([
26
                'name'   => 'Region',
27
                'fields' => [
28
                    'country' => new StringType(),
29
                    'city'    => new StringType()
30
                ],
31
            ]))
32
            ->addField('location', [
33
                 'type'    => new ObjectType(
34
                     [
35
                         'name'   => 'Location',
36
                         'fields' => [
37
                             'address'    => new StringType()
38
                         ]
39
                     ]
40
                 ),
41
                 'args'    => [
42
                     'noop' => new IntType()
43
                 ],
44
                 'resolve' => function ($value, $args, $info) {
0 ignored issues
show
Unused Code introduced by
The parameter $value 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...
Unused Code introduced by
The parameter $args 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...
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...
45
                   return ['address' => '1234 Street'];
46
                 }
47
             ]
48
            )
49
            ->addField(
50
                'echo', [
51
                    'type'    => new StringType(),
52
                    'args'    => [
53
                        'value' => new NonNullType(new StringType())
54
                    ],
55
                    '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...
56
                        return $args['value'];
57
                    }
58
                ]
59
            );
60
    }
61
62
    public function getInterfaces()
63
    {
64
        return [new TestInterfaceType()];
65
    }
66
67
    public function getData()
68
    {
69
        return [
70
            'id'   => 1,
71
            'name' => 'John'
72
        ];
73
    }
74
75
}
76