TypesField   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 7
dl 0
loc 36
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getType() 0 4 1
A getName() 0 4 1
A resolve() 0 16 3
1
<?php
2
/**
3
 * Date: 16.05.16
4
 *
5
 * @author Portey Vasil <[email protected]>
6
 */
7
8
namespace Youshido\GraphQL\Introspection\Field;
9
10
11
use Youshido\GraphQL\Execution\ResolveInfo;
12
use Youshido\GraphQL\Field\AbstractField;
13
use Youshido\GraphQL\Introspection\QueryType;
14
use Youshido\GraphQL\Introspection\Traits\TypeCollectorTrait;
15
use Youshido\GraphQL\Schema\AbstractSchema;
16
use Youshido\GraphQL\Type\ListType\ListType;
17
use Youshido\GraphQL\Type\Object\AbstractObjectType;
18
19
class TypesField extends AbstractField
20
{
21
22
    use TypeCollectorTrait;
23
24
    /**
25
     * @return AbstractObjectType
26
     */
27 12
    public function getType()
28
    {
29 12
        return new ListType(new QueryType());
30
    }
31
32 12
    public function getName()
33
    {
34 12
        return 'types';
35
    }
36
37 7
    public function resolve($value, array $args, ResolveInfo $info)
38
    {
39
        /** @var $value AbstractSchema $a */
40 7
        $this->types = [];
41 7
        $this->collectTypes($value->getQueryType());
42
43 7
        if ($value->getMutationType()->hasFields()) {
44 3
            $this->collectTypes($value->getMutationType());
45 3
        }
46
47 7
        foreach ($value->getTypesList()->getTypes() as $type) {
48 1
          $this->collectTypes($type);
49 7
        }
50
51 7
        return array_values($this->types);
52
    }
53
54
}
55