Passed
Pull Request — master (#301)
by Christoffer
03:16
created

AbstractTypeResolver::getResolver()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Digia\GraphQL\Schema\Resolver;
4
5
abstract class AbstractTypeResolver implements ResolverCollectionInterface
6
{
7
    use ResolverTrait;
8
9
    /**
10
     * @return callable|null
11
     */
12
    public function getResolveCallback(): ?callable
13
    {
14
        return function (string $fieldName) {
15
            return $this->getResolver($fieldName);
16
        };
17
    }
18
19
    /**
20
     * @param string $fieldName
21
     * @return callable|null
22
     */
23
    public function getResolver(string $fieldName): ?callable
24
    {
25
        $resolveMethod = 'resolve' . \ucfirst($fieldName);
26
27
        if (\method_exists($this, $resolveMethod)) {
28
            return [$this, $resolveMethod];
29
        }
30
31
        return null;
32
    }
33
}
34