ShipType   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 5
dl 0
loc 27
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 6 1
A getOne() 0 4 1
A getDescription() 0 4 1
A getInterfaces() 0 4 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