PropertyResolver::createFunction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 6
nc 1
nop 2
1
<?php
2
3
namespace Arthem\GraphQLMapper\Schema\Resolve;
4
5
use Arthem\GraphQLMapper\Mapping\Field;
6
use GraphQL\Type\Definition\ObjectType;
7
use GraphQL\Type\Definition\ResolveInfo;
8
9
class PropertyResolver extends SingletonResolver
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    public function getName()
15
    {
16
        return 'property';
17
    }
18
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function createFunction(array $config, Field $field)
23
    {
24
        return function ($node, array $arguments, ResolveInfo $info) {
25
            /** @var ObjectType $parentType */
26
            $parentType = $info->parentType;
27
            $field      = $parentType->getField($info->fieldName);
28
29
            $resolveConfig = $field->config['resolve_config'];
30
31
            return call_user_func([$node, $resolveConfig['method']]);
32
        };
33
    }
34
}
35