Passed
Push — master ( bda88f...2ab509 )
by Quang
06:38
created

ResolveInfo::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 10
dl 0
loc 22
rs 9.2
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A ResolveInfo::getReturnType() 0 3 1
A ResolveInfo::getParentType() 0 3 1

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
namespace Digia\GraphQL\Execution\Resolver;
4
5
use Digia\GraphQL\Config\ConfigObject;
6
use Digia\GraphQL\Execution\ResponsePath;
7
use Digia\GraphQL\Language\AST\Node\FieldNode;
8
use Digia\GraphQL\Language\AST\Node\OperationDefinitionNode;
9
use Digia\GraphQL\Type\Definition\ObjectType;
10
use Digia\GraphQL\Type\Definition\OutputTypeInterface;
11
use Digia\GraphQL\Type\SchemaInterface;
12
13
class ResolveInfo extends ConfigObject
14
{
15
    /**
16
     * @var string
17
     */
18
    protected $fieldName;
19
20
    /**
21
     * @var FieldNode[]
22
     */
23
    protected $fieldNodes;
24
25
    /**
26
     * @var OutputTypeInterface
27
     */
28
    protected $returnType;
29
30
    /**
31
     * @var ObjectType
32
     */
33
    protected $parentType;
34
35
    /**
36
     * @var ResponsePath
37
     */
38
    protected $path;
39
40
    /**
41
     * @var SchemaInterface
42
     */
43
    protected $schema;
44
45
    /**
46
     * @var array
47
     */
48
    protected $fragments;
49
50
    /**
51
     * @var mixed
52
     */
53
    protected $rootValue;
54
55
    /**
56
     * @var OperationDefinitionNode
57
     */
58
    protected $operation;
59
60
    /**
61
     * @var array
62
     */
63
    protected $variableValues;
64
65
    /**
66
     * @return string
67
     */
68
    public function getFieldName(): string
69
    {
70
        return $this->fieldName;
71
    }
72
73
    /**
74
     * @return FieldNode[]
75
     */
76
    public function getFieldNodes(): array
77
    {
78
        return $this->fieldNodes;
79
    }
80
81
    /**
82
     * @return OutputTypeInterface
83
     */
84
    public function getReturnType(): OutputTypeInterface
85
    {
86
        return $this->returnType;
87
    }
88
89
    /**
90
     * @return ObjectType
91
     */
92
    public function getParentType(): ObjectType
93
    {
94
        return $this->parentType;
95
    }
96
97
    /**
98
     * @return ResponsePath
99
     */
100
    public function getPath(): ResponsePath
101
    {
102
        return $this->path;
103
    }
104
105
    /**
106
     * @return SchemaInterface
107
     */
108
    public function getSchema(): SchemaInterface
109
    {
110
        return $this->schema;
111
    }
112
113
    /**
114
     * @return array
115
     */
116
    public function getFragments(): array
117
    {
118
        return $this->fragments;
119
    }
120
121
    /**
122
     * @return mixed
123
     */
124
    public function getRootValue()
125
    {
126
        return $this->rootValue;
127
    }
128
129
    /**
130
     * @return OperationDefinitionNode
131
     */
132
    public function getOperation(): OperationDefinitionNode
133
    {
134
        return $this->operation;
135
    }
136
137
    /**
138
     * @return array
139
     */
140
    public function getVariableValues(): array
141
    {
142
        return $this->variableValues;
143
    }
144
}
145