| Conditions | 1 |
| Paths | 1 |
| Total Lines | 187 |
| Code Lines | 94 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 7 | ||
| Bugs | 4 | 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 |
||
| 353 | public function queryProvider() |
||
| 354 | { |
||
| 355 | return [ |
||
| 356 | [ |
||
| 357 | '{ test (id: -5) { id } } ', |
||
| 358 | [ |
||
| 359 | 'queries' => [ |
||
| 360 | new Query('test', null, [ |
||
| 361 | new Argument('id', new Literal(-5)) |
||
| 362 | ], [ |
||
| 363 | new Field('id'), |
||
| 364 | ]) |
||
| 365 | ], |
||
| 366 | 'mutations' => [], |
||
| 367 | 'fragments' => [] |
||
| 368 | ] |
||
| 369 | ], |
||
| 370 | [ |
||
| 371 | 'query CheckTypeOfLuke { |
||
| 372 | hero(episode: EMPIRE) { |
||
| 373 | __typename, |
||
| 374 | name |
||
| 375 | } |
||
| 376 | }', |
||
| 377 | [ |
||
| 378 | 'queries' => [ |
||
| 379 | new Query('hero', null, [ |
||
| 380 | new Argument('episode', new Literal('EMPIRE')) |
||
| 381 | ], [ |
||
| 382 | new Field('__typename'), |
||
| 383 | new Field('name'), |
||
| 384 | ]) |
||
| 385 | ], |
||
| 386 | 'mutations' => [], |
||
| 387 | 'fragments' => [] |
||
| 388 | ] |
||
| 389 | ], |
||
| 390 | [ |
||
| 391 | '{ test { __typename, id } }', |
||
| 392 | [ |
||
| 393 | 'queries' => [ |
||
| 394 | new Query('test', null, [], [ |
||
| 395 | new Field('__typename'), |
||
| 396 | new Field('id'), |
||
| 397 | ]) |
||
| 398 | ], |
||
| 399 | 'mutations' => [], |
||
| 400 | 'fragments' => [] |
||
| 401 | ] |
||
| 402 | ], |
||
| 403 | [ |
||
| 404 | '{}', |
||
| 405 | [ |
||
| 406 | 'queries' => [], |
||
| 407 | 'mutations' => [], |
||
| 408 | 'fragments' => [] |
||
| 409 | ] |
||
| 410 | ], |
||
| 411 | [ |
||
| 412 | 'query test {}', |
||
| 413 | [ |
||
| 414 | 'queries' => [], |
||
| 415 | 'mutations' => [], |
||
| 416 | 'fragments' => [] |
||
| 417 | ] |
||
| 418 | ], |
||
| 419 | [ |
||
| 420 | 'query {}', |
||
| 421 | [ |
||
| 422 | 'queries' => [], |
||
| 423 | 'mutations' => [], |
||
| 424 | 'fragments' => [] |
||
| 425 | ] |
||
| 426 | ], |
||
| 427 | [ |
||
| 428 | 'mutation setName { setUserName }', |
||
| 429 | [ |
||
| 430 | 'queries' => [], |
||
| 431 | 'mutations' => [new Mutation('setUserName')], |
||
| 432 | 'fragments' => [] |
||
| 433 | ] |
||
| 434 | ], |
||
| 435 | [ |
||
| 436 | '{ test { ...userDataFragment } } fragment userDataFragment on User { id, name, email }', |
||
| 437 | [ |
||
| 438 | 'queries' => [ |
||
| 439 | new Query('test', null, [], [new FragmentReference('userDataFragment')]) |
||
| 440 | ], |
||
| 441 | 'mutations' => [], |
||
| 442 | 'fragments' => [ |
||
| 443 | new Fragment('userDataFragment', 'User', [ |
||
| 444 | new Field('id'), |
||
| 445 | new Field('name'), |
||
| 446 | new Field('email') |
||
| 447 | ]) |
||
| 448 | ] |
||
| 449 | ] |
||
| 450 | ], |
||
| 451 | [ |
||
| 452 | '{ user (id: 10, name: "max", float: 123.123 ) { id, name } }', |
||
| 453 | [ |
||
| 454 | 'queries' => [ |
||
| 455 | new Query( |
||
| 456 | 'user', |
||
| 457 | null, |
||
| 458 | [ |
||
| 459 | new Argument('id', new Literal('10')), |
||
| 460 | new Argument('name', new Literal('max')), |
||
| 461 | new Argument('float', new Literal('123.123')) |
||
| 462 | ], |
||
| 463 | [ |
||
| 464 | new Field('id'), |
||
| 465 | new Field('name') |
||
| 466 | ] |
||
| 467 | ) |
||
| 468 | ], |
||
| 469 | 'mutations' => [], |
||
| 470 | 'fragments' => [] |
||
| 471 | ] |
||
| 472 | ], |
||
| 473 | [ |
||
| 474 | '{ allUsers : users ( id: [ 1, 2, 3] ) { id } }', |
||
| 475 | [ |
||
| 476 | 'queries' => [ |
||
| 477 | new Query( |
||
| 478 | 'users', |
||
| 479 | 'allUsers', |
||
| 480 | [ |
||
| 481 | new Argument('id', new InputList([1, 2, 3])) |
||
| 482 | ], |
||
| 483 | [ |
||
| 484 | new Field('id') |
||
| 485 | ] |
||
| 486 | ) |
||
| 487 | ], |
||
| 488 | 'mutations' => [], |
||
| 489 | 'fragments' => [] |
||
| 490 | ] |
||
| 491 | ], |
||
| 492 | [ |
||
| 493 | '{ allUsers : users ( id: [ 1, "2", true, null] ) { id } }', |
||
| 494 | [ |
||
| 495 | 'queries' => [ |
||
| 496 | new Query( |
||
| 497 | 'users', |
||
| 498 | 'allUsers', |
||
| 499 | [ |
||
| 500 | new Argument('id', new InputList([1, "2", true, null])) |
||
| 501 | ], |
||
| 502 | [ |
||
| 503 | new Field('id') |
||
| 504 | ] |
||
| 505 | ) |
||
| 506 | ], |
||
| 507 | 'mutations' => [], |
||
| 508 | 'fragments' => [] |
||
| 509 | ] |
||
| 510 | ], |
||
| 511 | [ |
||
| 512 | '{ allUsers : users ( object: { "a": 123, "d": "asd", "b" : [ 1, 2, 4 ], "c": { "a" : 123, "b": "asd" } } ) { id } }', |
||
| 513 | [ |
||
| 514 | 'queries' => [ |
||
| 515 | new Query( |
||
| 516 | 'users', |
||
| 517 | 'allUsers', |
||
| 518 | [ |
||
| 519 | new Argument('object', new InputObject([ |
||
| 520 | 'a' => 123, |
||
| 521 | 'd' => 'asd', |
||
| 522 | 'b' => [1, 2, 4], |
||
| 523 | 'c' => [ |
||
| 524 | 'a' => 123, |
||
| 525 | 'b' => 'asd' |
||
| 526 | ] |
||
| 527 | ])) |
||
| 528 | ], |
||
| 529 | [ |
||
| 530 | new Field('id') |
||
| 531 | ] |
||
| 532 | ) |
||
| 533 | ], |
||
| 534 | 'mutations' => [], |
||
| 535 | 'fragments' => [] |
||
| 536 | ] |
||
| 537 | ] |
||
| 538 | ]; |
||
| 539 | } |
||
| 540 | |||
| 542 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.