Completed
Push — master ( d01340...7e7fa7 )
by Portey
07:36
created

DroidType::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * Date: 07.12.15
4
 *
5
 * @author Portey Vasil <[email protected]>
6
 */
7
8
namespace Youshido\Tests\Schema;
9
10
11
use Youshido\GraphQL\Type\Config\TypeConfigInterface;
12
use Youshido\GraphQL\Type\ListType\ListType;
13
use Youshido\GraphQL\Type\Object\AbstractObjectType;
14
use Youshido\GraphQL\Type\TypeMap;
15
16
class DroidType extends HumanType
17
{
18
19
    /**
20
     * @return String type name
21
     */
22
    public function getName()
23
    {
24
        return 'Droid';
25
    }
26
27
    protected function build(TypeConfigInterface $config)
28
    {
29
        parent::build($config);
30
31
        $config->getField('friends')->set('resolve', function($droid){
32
            return StarWarsData::getFriends($droid);
33
        });
34
35
        $config
36
            ->addField('primaryFunction', TypeMap::TYPE_STRING);
37
    }
38
39
    public function resolve($value = null, $args = [])
40
    {
41
        $droids = StarWarsData::droids();
42
43
        return isset($droids[$args['id']]) ? $droids[$args['id']] : null;
44
    }
45
46
47
}