Completed
Push — master ( 17976d...325209 )
by Portey
07:00
created

QueryType   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 1
Bugs 1 Features 1
Metric Value
wmc 4
c 1
b 1
f 1
lcom 0
cbo 7
dl 0
loc 30
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 3 1
A getName() 0 4 1
A build() 0 14 2
1
<?php
2
/**
3
 * Date: 07.12.15
4
 *
5
 * @author Portey Vasil <[email protected]>
6
 */
7
8
namespace Youshido\Tests\StarWars\Schema;
9
10
11
use Youshido\GraphQL\Type\Config\TypeConfigInterface;
12
use Youshido\GraphQL\Type\Object\AbstractObjectType;
13
14
class QueryType extends AbstractObjectType
15
{
16
17
    public function resolve($value = null, $args = [])
18
    {
19
    }
20
21
    /**
22
     * @return String type name
23
     */
24
    public function getName()
25
    {
26
        return 'Query';
27
    }
28
29
    protected function build(TypeConfigInterface $config)
30
    {
31
        $config
32
            ->addField('hero', new CharacterInterface(), [
33
                'args'    => [
34
                    'episode' => ['type' => new EpisodeEnum()]
35
                ],
36
                'resolve' => function ($root, $args) {
37
                    return StarWarsData::getHero(isset($args['episode']) ? $args['episode'] : null);
38
                },
39
            ])
40
            ->addField('human', new HumanType())
41
            ->addField('droid', new DroidType());
42
    }
43
}