Completed
Pull Request — master (#31)
by Sebastian
06:26 queued 02:32
created

FieldType   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 6
Bugs 2 Features 0
Metric Value
wmc 6
c 6
b 2
f 0
lcom 0
cbo 6
dl 0
loc 47
ccs 22
cts 22
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A resolveType() 0 4 1
A resolveArgs() 0 8 2
A build() 0 16 1
A isValidValue() 0 4 1
A getName() 0 4 1
1
<?php
2
/**
3
 * Date: 03.12.15
4
 *
5
 * @author Portey Vasil <[email protected]>
6
 */
7
8
namespace Youshido\GraphQL\Introspection;
9
10
use Youshido\GraphQL\Field\AbstractField;
11
use Youshido\GraphQL\Type\ListType\ListType;
12
use Youshido\GraphQL\Type\Object\AbstractObjectType;
13
use Youshido\GraphQL\Type\TypeMap;
14
15
class FieldType extends AbstractObjectType
16
{
17
18 3
    public static function resolveType(AbstractField $value)
19
    {
20 3
        return $value->getType();
21
    }
22
23 2
    public static function resolveArgs(AbstractField $value)
24
    {
25 2
        if ($value->getConfig()->hasArguments()) {
26 2
            return $value->getConfig()->getArguments();
27
        }
28
29 2
        return [];
30
    }
31
32 6
    public function build($config)
33
    {
34
        $config
35 6
            ->addField('name', TypeMap::TYPE_STRING)
36 6
            ->addField('description', TypeMap::TYPE_STRING)
37 6
            ->addField('isDeprecated', TypeMap::TYPE_BOOLEAN)
38 6
            ->addField('deprecationReason', TypeMap::TYPE_STRING)
39 6
            ->addField('type', [
40 6
                'type'    => new QueryType(),
41 6
                'resolve' => [get_class($this), 'resolveType'],
42
            ])
43 6
            ->addField('args', [
44 6
                'type'    => new ListType(new InputValueType()),
45 6
                'resolve' => [get_class($this), 'resolveArgs'],
46
            ]);
47 6
    }
48
49 4
    public function isValidValue($value)
50
    {
51 4
        return $value instanceof AbstractField;
52
    }
53
54
    /**
55
     * @return String type name
56
     */
57 7
    public function getName()
58
    {
59 7
        return '__Field';
60
    }
61
}
62