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

NodeInterfaceType::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
ccs 0
cts 3
cp 0
cc 1
eloc 2
nc 1
nop 1
crap 2
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