Passed
Push — master ( 974e77...edaba1 )
by Christoffer
02:10
created

ResolveTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setResolve() 0 4 1
A resolve() 0 3 2
1
<?php
2
3
namespace Digia\GraphQL\Type\Definition;
4
5
trait ResolveTrait
6
{
7
8
    /**
9
     * @var ?callable
10
     */
0 ignored issues
show
Documentation Bug introduced by
The doc comment ?callable at position 0 could not be parsed: Unknown type name '?callable' at position 0 in ?callable.
Loading history...
11
    private $_resolveFunction;
12
13
    /**
14
     * @param array ...$args
15
     * @return mixed
16
     */
17
    public function resolve(...$args)
18
    {
19
        return $this->_resolveFunction !== null ? call_user_func_array($this->_resolveFunction, $args) : null;
20
    }
21
22
    /**
23
     * @param callable $resolveFunction
24
     * @return $this
25
     */
26
    protected function setResolve(callable $resolveFunction)
27
    {
28
        $this->_resolveFunction = $resolveFunction;
29
        return $this;
30
    }
31
}
32