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

NodeInterfaceType   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 78.56%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 45
rs 10
ccs 11
cts 14
cp 0.7856

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A build() 0 4 1
A resolveType() 0 8 2
A getFetcher() 0 4 1
A setFetcher() 0 6 1
1
<?php
2
/*
3
* This file is a part of GraphQL project.
4
*
5
* @author Alexandr Viniychuk <[email protected]>
6
* created: 5/10/16 11:32 PM
7
*/
8
9
namespace Youshido\GraphQL\Relay;
10
11
12
use Youshido\GraphQL\Relay\Fetcher\FetcherInterface;
13
use Youshido\GraphQL\Relay\Field\GlobalIdField;
14
use Youshido\GraphQL\Type\InterfaceType\AbstractInterfaceType;
15
16
class NodeInterfaceType extends AbstractInterfaceType
17
{
18
19
    /** @var  FetcherInterface */ //todo: maybe there are better solution
20
    protected $fetcher;
21
22 2
    public function getName()
23
    {
24 2
        return 'NodeInterface';
25
    }
26
27
    public function build($config)
28
    {
29
        $config->addField(new GlobalIdField('NodeInterface'));
30
    }
31
32 1
    public function resolveType($object)
33
    {
34 1
        if ($this->fetcher) {
35 1
            return $this->fetcher->resolveType($object);
36
        }
37
38 1
        return null;
39
    }
40
41
    /**
42
     * @return FetcherInterface
43
     */
44 2
    public function getFetcher()
45
    {
46 2
        return $this->fetcher;
47
    }
48
49
    /**
50
     * @param FetcherInterface $fetcher
51
     *
52
     * @return NodeInterfaceType
53
     */
54 2
    public function setFetcher($fetcher)
55
    {
56 2
        $this->fetcher = $fetcher;
57
58 2
        return $this;
59
    }
60
}
61