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

DroidType   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 0
cbo 4
dl 0
loc 32
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A build() 0 11 1
A resolve() 0 6 2
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
}