Completed
Push — master ( 3a14e9...fe7442 )
by Portey
04:17
created

FieldType::build()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 19
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 2.0018

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 19
ccs 12
cts 13
cp 0.9231
rs 9.4286
cc 2
eloc 12
nc 1
nop 1
crap 2.0018
1
<?php
2
/**
3
 * Date: 03.12.15
4
 *
5
 * @author Portey Vasil <[email protected]>
6
 */
7
8
namespace Youshido\GraphQL\Introspection;
9
10
11
use Youshido\GraphQL\Type\Config\TypeConfigInterface;
12
use Youshido\GraphQL\Type\Field\Field;
13
use Youshido\GraphQL\Type\Object\AbstractObjectType;
14
use Youshido\GraphQL\Type\TypeMap;
15
16
class FieldType extends AbstractObjectType
17
{
18
19 4
    protected function build(TypeConfigInterface $config)
20
    {
21
        $config
22 4
            ->addField('name', TypeMap::TYPE_STRING)
23 4
            ->addField('description', TypeMap::TYPE_STRING)
24 4
            ->addField('isDeprecated', TypeMap::TYPE_BOOLEAN)
25 4
            ->addField('deprecationReason', TypeMap::TYPE_STRING)
26 4
            ->addField('type', new QueryType(), [
27 2
                'resolve' => function($value, $args) {
0 ignored issues
show
Unused Code introduced by
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
28
                    /** @var $value Field */
29 2
                    if($value->getConfig()->getType()->getKind() == TypeMap::KIND_INPUT_OBJECT) {
30
                        return $value->getConfig()->getType()->getConfig()->getOutputType();
31
                    }
32
33 2
                    return $value->getType();
34
                }
35 4
            ])
36 4
            ->addField('args', new InputValueListType());
37 4
    }
38
39
    public function resolve($value = null, $args = [])
40
    {
41
        /** @var $value Field */
42
        return $value->getType();
43
    }
44
45
    /**
46
     * @return String type name
47
     */
48 6
    public function getName()
49
    {
50 6
        return '__Field';
51
    }
52
}