Completed
Push — master ( d52ee7...e7842c )
by Alexandr
03:54
created

FieldType::isValidValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
ccs 2
cts 2
cp 1
cc 1
eloc 2
nc 1
nop 1
crap 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 6
    public function build($config)
19
    {
20
        $config
21 6
            ->addField('name', TypeMap::TYPE_STRING)
22 6
            ->addField('description', TypeMap::TYPE_STRING)
23 6
            ->addField('isDeprecated', TypeMap::TYPE_BOOLEAN)
24 6
            ->addField('deprecationReason', TypeMap::TYPE_STRING)
25 6
            ->addField('type', [
26 6
                'type'    => new QueryType(),
27
                'resolve' => function (AbstractField $value) {
28 3
                    return $value->getType()->getNamedType();
29
                }
30 6
            ])
31 6
            ->addField('args', [
32 6
                'type'    => new ListType(new InputValueType()),
33 2
                'resolve' => function (AbstractField $value) {
34 2
                    if ($value->getConfig()->hasArguments()) {
35 2
                        return $value->getConfig()->getArguments();
36
                    }
37
38 2
                    return [];
39
                }
40 6
            ]);
41 6
    }
42
43 4
    public function isValidValue($value)
44
    {
45 4
        return $value instanceof AbstractField;
46
    }
47
48
    /**
49
     * @return String type name
50
     */
51 7
    public function getName()
52
    {
53 7
        return '__Field';
54
    }
55
}
56