Completed
Pull Request — master (#187)
by Christoffer
04:45 queued 02:07
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
class AbstractResolver implements ResolverInterface
8
{
9
    /**
10
     * @inheritdoc
11
     */
12
    public function getResolveMethod(string $fieldName): ?callable
13
    {
14
        $resolveMethod = 'resolve' . \ucfirst($fieldName);
15
16
        if (\method_exists($this, $resolveMethod)) {
17
            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...
18
        }
19
20
        return null;
21
    }
22
23
    /**
24
     * @inheritdoc
25
     */
26
    public function getTypeResolver(): ?callable
27
    {
28
        return function ($rootValue, $contextValues, ResolveInfo $info) {
29
            return $this->resolveType($rootValue, $contextValues, $info);
30
        };
31
    }
32
33
    /**
34
     * @param mixed       $rootValue
35
     * @param mixed       $contextValues
36
     * @param ResolveInfo $info
37
     * @return callable|null
38
     */
39
    protected function resolveType($rootValue, $contextValues, ResolveInfo $info): ?callable
0 ignored issues
show
Unused Code introduced by
The parameter $contextValues is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

39
    protected function resolveType($rootValue, /** @scrutinizer ignore-unused */ $contextValues, ResolveInfo $info): ?callable

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $info is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

39
    protected function resolveType($rootValue, $contextValues, /** @scrutinizer ignore-unused */ ResolveInfo $info): ?callable

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $rootValue is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

39
    protected function resolveType(/** @scrutinizer ignore-unused */ $rootValue, $contextValues, ResolveInfo $info): ?callable

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
40
    {
41
        return null;
42
    }
43
}
44