PropertyResolver   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 26
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A createFunction() 0 12 1
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