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

CallableFetcher::resolveNode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 6
rs 9.4285
ccs 3
cts 3
cp 1
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
/**
3
 * Date: 17.05.16
4
 *
5
 * @author Portey Vasil <[email protected]>
6
 */
7
8
namespace Youshido\GraphQL\Relay\Fetcher;
9
10
11
class CallableFetcher implements FetcherInterface
12
{
13
14
    /** @var  callable */
15
    protected $resolveNodeCallable;
16
17
    /** @var  callable */
18
    protected $resolveTypeCallable;
19
20 3
    public function __construct(callable $resolveNode, callable $resolveType)
21
    {
22 3
        $this->resolveNodeCallable = $resolveNode;
23 3
        $this->resolveTypeCallable = $resolveType;
24 3
    }
25
26
    /**
27
     * @inheritdoc
28
     */
29 1
    public function resolveNode($type, $id)
30
    {
31 1
        $callable = $this->resolveNodeCallable;
32
33 1
        return $callable($type, $id);
34
    }
35
36
    /**
37
     * @inheritdoc
38
     */
39 2
    public function resolveType($object)
40
    {
41 2
        $callable = $this->resolveTypeCallable;
42
43 2
        return $callable($object);
44
    }
45
}