Completed
Push — master ( 6c95d8...49bfd8 )
by Christoffer
03:47 queued 01:30
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\AST\Node\FieldNode;
6
use Digia\GraphQL\Language\AST\Node\OperationDefinitionNode;
7
use Digia\GraphQL\Type\Definition\ObjectType;
8
use Digia\GraphQL\Type\Definition\OutputTypeInterface;
9
use Digia\GraphQL\Type\SchemaInterface;
10
11
class ResolveInfo
12
{
13
    /**
14
     * @var string
15
     */
16
    protected $fieldName;
17
18
    /**
19
     * @var FieldNode[]
20
     */
21
    protected $fieldNodes;
22
23
    /**
24
     * @var OutputTypeInterface
25
     */
26
    protected $returnType;
27
28
    /**
29
     * @var ObjectType
30
     */
31
    protected $parentType;
32
33
    /**
34
     * @var ResponsePath
35
     */
36
    protected $path;
37
38
    /**
39
     * @var SchemaInterface
40
     */
41
    protected $schema;
42
43
    /**
44
     * @var array
45
     */
46
    protected $fragments;
47
48
    /**
49
     * @var mixed
50
     */
51
    protected $rootValue;
52
53
    /**
54
     * @var OperationDefinitionNode
55
     */
56
    protected $operation;
57
58
    /**
59
     * @var array
60
     */
61
    protected $variableValues;
62
63
    /**
64
     * ResolveInfo constructor.
65
     *
66
     * @param string                  $fieldName
67
     * @param FieldNode[]             $fieldNodes
68
     * @param OutputTypeInterface     $returnType
69
     * @param ObjectType              $parentType
70
     * @param ResponsePath            $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
        OutputTypeInterface $returnType,
81
        ObjectType $parentType,
82
        ResponsePath $path,
83
        SchemaInterface $schema,
84
        array $fragments,
85
        mixed $rootValue,
0 ignored issues
show
Bug introduced by
The type Digia\GraphQL\Execution\mixed was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

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