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

TypeDefinitionType   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 92.86%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 32
ccs 13
cts 14
cp 0.9286
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 13 3
A getName() 0 4 1
A build() 0 6 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
}