Completed
Pull Request — master (#270)
by Christoffer
02:27
created

AbstractResolver::resolveType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 3
1
<?php
2
3
namespace Digia\GraphQL\Schema\Resolver;
4
5
use Digia\GraphQL\Execution\ResolveInfo;
6
7
abstract class AbstractResolver implements ResolverInterface
8
{
9
    /**
10
     * @param mixed       $rootValue
11
     * @param mixed       $contextValues
12
     * @param ResolveInfo $info
13
     * @return callable|null
14
     */
15
    abstract public function resolveType($rootValue, $contextValues, ResolveInfo $info): ?callable;
16
17
    /**
18
     * @inheritdoc
19
     */
20
    public function getResolveMethod(string $fieldName): ?callable
21
    {
22
        $resolveMethod = 'resolve' . \ucfirst($fieldName);
23
24
        if (\method_exists($this, $resolveMethod)) {
25
            return [$this, $resolveMethod];
0 ignored issues
show
Bug Best Practice introduced by
The expression return array($this, $resolveMethod) returns the type array<integer,Digia\Grap...bstractResolver|string> which is incompatible with the type-hinted return null|callable.
Loading history...
26
        }
27
28
        return null;
29
    }
30
31
    /**
32
     * @inheritdoc
33
     */
34
    public function getTypeResolver(): ?callable
35
    {
36
        return function ($rootValue, $contextValues, ResolveInfo $info) {
37
            return $this->resolveType($rootValue, $contextValues, $info);
38
        };
39
    }
40
}
41