ShipType::build()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/*
3
* This file is a part of GraphQL project.
4
*
5
* @author Alexandr Viniychuk <[email protected]>
6
* created: 5/10/16 11:17 PM
7
*/
8
9
namespace Examples\StarWars;
10
11
12
use Youshido\GraphQL\Relay\Field\GlobalIdField;
13
use Youshido\GraphQL\Relay\NodeInterfaceType;
14
use Youshido\GraphQL\Type\Object\AbstractObjectType;
15
use Youshido\GraphQL\Type\TypeMap;
16
17
class ShipType extends AbstractObjectType
18
{
19
    const TYPE_KEY = 'ship';
20
21
    public function build($config)
22
    {
23
        $config
24
            ->addField(new GlobalIdField(self::TYPE_KEY))
25
            ->addField('name', ['type' => TypeMap::TYPE_STRING, 'description' => 'The name of the ship.']);
26
    }
27
28
    public function getOne($id)
29
    {
30
        return TestDataProvider::getShip($id);
31
    }
32
33
    public function getDescription()
34
    {
35
        return 'A ship in the Star Wars saga';
36
    }
37
38
    public function getInterfaces()
39
    {
40
        return [new NodeInterfaceType()];
41
    }
42
43
}
44