Conditions | 1 |
Paths | 1 |
Total Lines | 173 |
Code Lines | 87 |
Lines | 0 |
Ratio | 0 % |
Changes | 6 | ||
Bugs | 3 | 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 |
||
269 | public function queryProvider() |
||
270 | { |
||
271 | return [ |
||
272 | [ |
||
273 | 'query CheckTypeOfLuke { |
||
274 | hero(episode: EMPIRE) { |
||
275 | __typename, |
||
276 | name |
||
277 | } |
||
278 | }', |
||
279 | [ |
||
280 | 'queries' => [ |
||
281 | new Query('hero', null, [ |
||
282 | new Argument('episode', new Literal('EMPIRE')) |
||
283 | ], [ |
||
284 | new Field('__typename'), |
||
285 | new Field('name'), |
||
286 | ]) |
||
287 | ], |
||
288 | 'mutations' => [], |
||
289 | 'fragments' => [] |
||
290 | ] |
||
291 | ], |
||
292 | [ |
||
293 | '{ test { __typename, id } }', |
||
294 | [ |
||
295 | 'queries' => [ |
||
296 | new Query('test', null, [], [ |
||
297 | new Field('__typename'), |
||
298 | new Field('id'), |
||
299 | ]) |
||
300 | ], |
||
301 | 'mutations' => [], |
||
302 | 'fragments' => [] |
||
303 | ] |
||
304 | ], |
||
305 | [ |
||
306 | '{}', |
||
307 | [ |
||
308 | 'queries' => [], |
||
309 | 'mutations' => [], |
||
310 | 'fragments' => [] |
||
311 | ] |
||
312 | ], |
||
313 | [ |
||
314 | 'query test {}', |
||
315 | [ |
||
316 | 'queries' => [], |
||
317 | 'mutations' => [], |
||
318 | 'fragments' => [] |
||
319 | ] |
||
320 | ], |
||
321 | [ |
||
322 | 'query {}', |
||
323 | [ |
||
324 | 'queries' => [], |
||
325 | 'mutations' => [], |
||
326 | 'fragments' => [] |
||
327 | ] |
||
328 | ], |
||
329 | [ |
||
330 | 'mutation setName { setUserName }', |
||
331 | [ |
||
332 | 'queries' => [], |
||
333 | 'mutations' => [new Mutation('setUserName')], |
||
334 | 'fragments' => [] |
||
335 | ] |
||
336 | ], |
||
337 | [ |
||
338 | '{ test { ...userDataFragment } } fragment userDataFragment on User { id, name, email }', |
||
339 | [ |
||
340 | 'queries' => [ |
||
341 | new Query('test', null, [], [new FragmentReference('userDataFragment')]) |
||
342 | ], |
||
343 | 'mutations' => [], |
||
344 | 'fragments' => [ |
||
345 | new Fragment('userDataFragment', 'User', [ |
||
346 | new Field('id'), |
||
347 | new Field('name'), |
||
348 | new Field('email') |
||
349 | ]) |
||
350 | ] |
||
351 | ] |
||
352 | ], |
||
353 | [ |
||
354 | '{ user (id: 10, name: "max", float: 123.123 ) { id, name } }', |
||
355 | [ |
||
356 | 'queries' => [ |
||
357 | new Query( |
||
358 | 'user', |
||
359 | null, |
||
360 | [ |
||
361 | new Argument('id', new Literal('10')), |
||
362 | new Argument('name', new Literal('max')), |
||
363 | new Argument('float', new Literal('123.123')) |
||
364 | ], |
||
365 | [ |
||
366 | new Field('id'), |
||
367 | new Field('name') |
||
368 | ] |
||
369 | ) |
||
370 | ], |
||
371 | 'mutations' => [], |
||
372 | 'fragments' => [] |
||
373 | ] |
||
374 | ], |
||
375 | [ |
||
376 | '{ allUsers : users ( id: [ 1, 2, 3] ) { id } }', |
||
377 | [ |
||
378 | 'queries' => [ |
||
379 | new Query( |
||
380 | 'users', |
||
381 | 'allUsers', |
||
382 | [ |
||
383 | new Argument('id', new InputList([1, 2, 3])) |
||
384 | ], |
||
385 | [ |
||
386 | new Field('id') |
||
387 | ] |
||
388 | ) |
||
389 | ], |
||
390 | 'mutations' => [], |
||
391 | 'fragments' => [] |
||
392 | ] |
||
393 | ], |
||
394 | [ |
||
395 | '{ allUsers : users ( id: [ 1, "2", true, null] ) { id } }', |
||
396 | [ |
||
397 | 'queries' => [ |
||
398 | new Query( |
||
399 | 'users', |
||
400 | 'allUsers', |
||
401 | [ |
||
402 | new Argument('id', new InputList([1, "2", true, null])) |
||
403 | ], |
||
404 | [ |
||
405 | new Field('id') |
||
406 | ] |
||
407 | ) |
||
408 | ], |
||
409 | 'mutations' => [], |
||
410 | 'fragments' => [] |
||
411 | ] |
||
412 | ], |
||
413 | [ |
||
414 | '{ allUsers : users ( object: { "a": 123, "d": "asd", "b" : [ 1, 2, 4 ], "c": { "a" : 123, "b": "asd" } } ) { id } }', |
||
415 | [ |
||
416 | 'queries' => [ |
||
417 | new Query( |
||
418 | 'users', |
||
419 | 'allUsers', |
||
420 | [ |
||
421 | new Argument('object', new InputObject([ |
||
422 | 'a' => 123, |
||
423 | 'd' => 'asd', |
||
424 | 'b' => [1, 2, 4], |
||
425 | 'c' => [ |
||
426 | 'a' => 123, |
||
427 | 'b' => 'asd' |
||
428 | ] |
||
429 | ])) |
||
430 | ], |
||
431 | [ |
||
432 | new Field('id') |
||
433 | ] |
||
434 | ) |
||
435 | ], |
||
436 | 'mutations' => [], |
||
437 | 'fragments' => [] |
||
438 | ] |
||
439 | ] |
||
440 | ]; |
||
441 | } |
||
442 | |||
443 | } |