Passed
Push — master ( b86485...6a0ac7 )
by Christoffer
03:03
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

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;
4
5
use Digia\GraphQL\Language\Node\FieldNode;
6
use Digia\GraphQL\Language\Node\OperationDefinitionNode;
7
use Digia\GraphQL\Type\Definition\ObjectType;
8
use Digia\GraphQL\Type\Definition\OutputTypeInterface;
9
use Digia\GraphQL\Type\Definition\TypeInterface;
10
use Digia\GraphQL\Type\SchemaInterface;
11
12
class ResolveInfo
13
{
14
    /**
15
     * @var string
16
     */
17
    protected $fieldName;
18
19
    /**
20
     * @var FieldNode[]
21
     */
22
    protected $fieldNodes;
23
24
    /**
25
     * @var OutputTypeInterface
26
     */
27
    protected $returnType;
28
29
    /**
30
     * @var ObjectType
31
     */
32
    protected $parentType;
33
34
    /**
35
     * @var array|null
36
     */
37
    protected $path;
38
39
    /**
40
     * @var SchemaInterface
41
     */
42
    protected $schema;
43
44
    /**
45
     * @var array
46
     */
47
    protected $fragments;
48
49
    /**
50
     * @var mixed
51
     */
52
    protected $rootValue;
53
54
    /**
55
     * @var OperationDefinitionNode
56
     */
57
    protected $operation;
58
59
    /**
60
     * @var array
61
     */
62
    protected $variableValues;
63
64
    /**
65
     * ResolveInfo constructor.
66
     * @param string                  $fieldName
67
     * @param FieldNode[]             $fieldNodes
68
     * @param TypeInterface           $returnType
69
     * @param ObjectType              $parentType
70
     * @param array|null              $path
71
     * @param SchemaInterface         $schema
72
     * @param array                   $fragments
73
     * @param mixed                   $rootValue
74
     * @param OperationDefinitionNode $operation
75
     * @param array                   $variableValues
76
     */
77
    public function __construct(
78
        string $fieldName,
79
        ?array $fieldNodes,
80
        TypeInterface $returnType,
81
        ObjectType $parentType,
82
        ?array $path,
83
        SchemaInterface $schema,
84
        array $fragments,
85
        $rootValue,
86
        OperationDefinitionNode $operation,
87
        array $variableValues
88
    ) {
89
        $this->fieldName      = $fieldName;
90
        $this->fieldNodes     = $fieldNodes;
91
        $this->returnType     = $returnType;
0 ignored issues
show
Documentation Bug introduced by
It seems like $returnType of type Digia\GraphQL\Type\Definition\TypeInterface is incompatible with the declared type Digia\GraphQL\Type\Definition\OutputTypeInterface of property $returnType.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
92
        $this->parentType     = $parentType;
93
        $this->path           = $path;
94
        $this->schema         = $schema;
95
        $this->fragments      = $fragments;
96
        $this->rootValue      = $rootValue;
97
        $this->operation      = $operation;
98
        $this->variableValues = $variableValues;
99
    }
100
101
102
    /**
103
     * @return string
104
     */
105
    public function getFieldName(): string
106
    {
107
        return $this->fieldName;
108
    }
109
110
    /**
111
     * @return FieldNode[]
112
     */
113
    public function getFieldNodes(): array
114
    {
115
        return $this->fieldNodes;
116
    }
117
118
    /**
119
     * @return OutputTypeInterface
120
     */
121
    public function getReturnType(): OutputTypeInterface
122
    {
123
        return $this->returnType;
124
    }
125
126
    /**
127
     * @return ObjectType
128
     */
129
    public function getParentType(): ObjectType
130
    {
131
        return $this->parentType;
132
    }
133
134
    /**
135
     * @return array
136
     */
137
    public function getPath(): ?array
138
    {
139
        return $this->path;
140
    }
141
142
    /**
143
     * @return SchemaInterface
144
     */
145
    public function getSchema(): SchemaInterface
146
    {
147
        return $this->schema;
148
    }
149
150
    /**
151
     * @return array
152
     */
153
    public function getFragments(): array
154
    {
155
        return $this->fragments;
156
    }
157
158
    /**
159
     * @return mixed
160
     */
161
    public function getRootValue()
162
    {
163
        return $this->rootValue;
164
    }
165
166
    /**
167
     * @return OperationDefinitionNode
168
     */
169
    public function getOperation(): OperationDefinitionNode
170
    {
171
        return $this->operation;
172
    }
173
174
    /**
175
     * @return array
176
     */
177
    public function getVariableValues(): array
178
    {
179
        return $this->variableValues;
180
    }
181
}
182