Passed
Push — master ( bda88f...2ab509 )
by Quang
06:38
created

ResolveTrait::hasResolve()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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
     * @return callable|null
24
     */
25
    public function getResolve(): ?callable
26
    {
27
        return $this->_resolveFunction;
28
    }
29
30
    /**
31
     * @return bool
32
     */
33
    public function hasResolve()
34
    {
35
        return $this->_resolveFunction !== null;
36
    }
37
38
    /**
39
     * Because of the use of ConfigTrait, setter name must match with attribute in $config array
40
     *
41
     * @param callable $resolveFunction
42
     * @return $this
43
     */
44
    protected function setResolve(callable $resolveFunction)
45
    {
46
        $this->_resolveFunction = $resolveFunction;
47
        return $this;
48
    }
49
}
50