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

TypeDefinitionType::getName()   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
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
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\Type\Config\TypeConfigInterface;
11
use Youshido\GraphQL\Type\TypeMap;
12
13
class TypeDefinitionType extends QueryType
14
{
15
16 1
    public function resolve($value = null, $args = [])
17
    {
18 1
        $this->collectTypes(SchemaType::$schema->getQueryType());
19 1
        $this->collectTypes(SchemaType::$schema->getMutationType());
20
21 1
        foreach ($this->types as $name => $type) {
22 1
            if ($name == $args['name']) {
23 1
                return $type;
24
            }
25 1
        }
26
27
        return null;
28
    }
29
30
    /**
31
     * @return String type name
32
     */
33 18
    public function getName()
34
    {
35 18
        return '__Type';
36
    }
37
38 4
    protected function build(TypeConfigInterface $config)
39
    {
40 4
        parent::build($config);
41
42 4
        $config->addArgument('name', TypeMap::TYPE_STRING, ['required' => true]);
43
    }
44
}