Conditions | 1 |
Paths | 1 |
Total Lines | 162 |
Code Lines | 74 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
93 | public static function providerExecute(): iterable |
||
94 | { |
||
95 | yield 'empty body' => [ |
||
96 | '', |
||
97 | [ |
||
98 | 'errors' => [ |
||
99 | [ |
||
100 | 'message' => 'GraphQL Request must include at least one of those two parameters: "query" or "queryId"', |
||
101 | ], |
||
102 | ], |
||
103 | ], |
||
104 | ]; |
||
105 | |||
106 | yield 'invalid json' => [ |
||
107 | 'foo bar', |
||
108 | [ |
||
109 | 'errors' => [ |
||
110 | [ |
||
111 | 'message' => 'GraphQL Request must include at least one of those two parameters: "query" or "queryId"', |
||
112 | ], |
||
113 | ], |
||
114 | ], |
||
115 | ]; |
||
116 | |||
117 | yield 'empty query' => [ |
||
118 | '{"query": ""}', |
||
119 | [ |
||
120 | 'errors' => [ |
||
121 | [ |
||
122 | 'message' => 'GraphQL Request must include at least one of those two parameters: "query" or "queryId"', |
||
123 | ], |
||
124 | ], |
||
125 | ], |
||
126 | ]; |
||
127 | |||
128 | yield 'normal' => [ |
||
129 | '{"query": "{ __typename }"}', |
||
130 | [ |
||
131 | 'data' => [ |
||
132 | '__typename' => 'Query', |
||
133 | ], |
||
134 | ], |
||
135 | ]; |
||
136 | |||
137 | yield 'native exception' => [ |
||
138 | '{"query": "{ nativeException }"}', |
||
139 | [ |
||
140 | 'errors' => [ |
||
141 | [ |
||
142 | 'message' => 'Internal server error', |
||
143 | 'locations' => [ |
||
144 | [ |
||
145 | 'line' => 1, |
||
146 | 'column' => 3, |
||
147 | ], |
||
148 | ], |
||
149 | 'path' => [ |
||
150 | 'nativeException', |
||
151 | ], |
||
152 | ], |
||
153 | ], |
||
154 | 'data' => [ |
||
155 | 'nativeException' => null, |
||
156 | ], |
||
157 | ], |
||
158 | <<<STRING |
||
159 | Fake message |
||
160 | |||
161 | GraphQL request (1:3) |
||
162 | 1: { nativeException } |
||
163 | ^ |
||
164 | |||
165 | STRING |
||
166 | ]; |
||
167 | |||
168 | yield 'Felix exception shows snackbar' => [ |
||
169 | '{"query": "{ felixException }"}', |
||
170 | [ |
||
171 | 'errors' => [ |
||
172 | [ |
||
173 | 'message' => 'Fake message', |
||
174 | 'locations' => [ |
||
175 | [ |
||
176 | 'line' => 1, |
||
177 | 'column' => 3, |
||
178 | ], |
||
179 | ], |
||
180 | 'path' => [ |
||
181 | 'felixException', |
||
182 | ], |
||
183 | 'extensions' => [ |
||
184 | 'showSnack' => true, |
||
185 | ], |
||
186 | ], |
||
187 | ], |
||
188 | 'data' => [ |
||
189 | 'felixException' => null, |
||
190 | ], |
||
191 | ], |
||
192 | <<<STRING |
||
193 | Fake message |
||
194 | |||
195 | GraphQL request (1:3) |
||
196 | 1: { felixException } |
||
197 | ^ |
||
198 | |||
199 | STRING |
||
200 | ]; |
||
201 | |||
202 | yield 'not found exception does not show snackbar but is flagged' => [ |
||
203 | '{"query": "{ notFoundException }"}', |
||
204 | [ |
||
205 | 'errors' => [ |
||
206 | [ |
||
207 | 'message' => 'Entity not found for class `foo` and ID `bar`.', |
||
208 | 'locations' => [ |
||
209 | [ |
||
210 | 'line' => 1, |
||
211 | 'column' => 3, |
||
212 | ], |
||
213 | ], |
||
214 | 'path' => [ |
||
215 | 'notFoundException', |
||
216 | ], |
||
217 | 'extensions' => [ |
||
218 | 'objectNotFound' => true, |
||
219 | ], |
||
220 | ], |
||
221 | ], |
||
222 | 'data' => [ |
||
223 | 'notFoundException' => null, |
||
224 | ], |
||
225 | ], |
||
226 | <<<STRING |
||
227 | Entity not found for class `foo` and ID `bar`. |
||
228 | |||
229 | GraphQL request (1:3) |
||
230 | 1: { notFoundException } |
||
231 | ^ |
||
232 | |||
233 | STRING |
||
234 | ]; |
||
235 | |||
236 | yield 'invalidVariables shows snackbar' => [ |
||
237 | '{"query": "query ($v: Boolean) { invalidVariables(myArg: $v) }", "variables": {"v": 123}}', |
||
238 | [ |
||
239 | 'errors' => [ |
||
240 | [ |
||
241 | 'message' => 'Variable "$v" got invalid value 123; Boolean cannot represent a non boolean value: 123', |
||
242 | 'locations' => [ |
||
243 | [ |
||
244 | 'line' => 1, |
||
245 | 'column' => 8, |
||
246 | ], |
||
247 | ], |
||
248 | 'extensions' => [ |
||
249 | 'showSnack' => true, |
||
250 | ], |
||
251 | ], |
||
252 | ], |
||
253 | ], |
||
254 | <<<STRING |
||
255 | Variable "\$v" got invalid value 123; Boolean cannot represent a non boolean value: 123 |
||
265 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.