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

CallableFetcher   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 3
c 1
b 1
f 0
lcom 2
cbo 0
dl 0
loc 35
rs 10
ccs 10
cts 10
cp 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A resolveNode() 0 6 1
A resolveType() 0 6 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
}